olekukonko / tablewriter
ASCII table in golang
AI Architecture Analysis
This repository is indexed by RepoMind. By analyzing olekukonko/tablewriter in our AI interface, you can instantly generate complete architecture diagrams, visualize control flows, and perform automated security audits across the entire codebase.
Our Agentic Context Augmented Generation (Agentic CAG) engine loads full source files into context on-demand, avoiding the fragmentation of traditional RAG systems. Ask questions about the architecture, dependencies, or specific features to see it in action.
Repository Overview (README excerpt)
Crawler viewTableWriter for Go is a Go library for generating **rich text-based tables** with support for multiple output formats, including ASCII, Unicode, Markdown, HTML, and colorized terminals. Perfect for CLI tools, logs, and web applications. Key Features • **Multi-format rendering**: ASCII, Unicode, Markdown, HTML, ANSI-colored • **Advanced styling**: Cell merging, alignment, padding, borders • **Flexible input**: CSV, structs, slices, or streaming data • **High performance**: Minimal allocations, buffer reuse • **Modern features**: Generics support, hierarchical merging, real-time streaming --- Installation Legacy Version (v0.0.5) For use with legacy applications: Latest Version The latest stable version **Warning:** Version contains missing functionality and should not be used. > **Version Guidance** > - Legacy: Use (stable) > - New Features: Use (includes generics, super fast streaming APIs) > - Legacy Docs: See README_LEGACY.md --- Why TableWriter? • **CLI Ready**: Instant compatibility with terminal outputs • **Database Friendly**: Native support for types • **Secure**: Auto-escaping for HTML/Markdown • **Extensible**: Custom renderers and formatters --- Quick Example **Output**: Detailed Usage Create a table with or , configure it using options or a struct, add data with or , and render to an . Use renderers like (ASCII), , , , or (streaming). Here's how the API primitives map to the generated ASCII table: The core components include: • **Renderer** - Implements the core interface for converting table data into output formats. Available renderers include Blueprint (ASCII), HTML, Markdown, Colorized (ASCII with color), Ocean (streaming ASCII), and SVG. • **Config** - The root configuration struct that controls all table behavior and appearance • **Behavior** - Controls high-level rendering behaviors including auto-hiding empty columns, trimming row whitespace, header/footer visibility, and compact mode for optimized merged cell calculations • **CellConfig** - The comprehensive configuration template used for table sections (header, row, footer). Combines formatting, padding, alignment, filtering, callbacks, and width constraints with global and per-column control • **StreamConfig** - Configuration for streaming mode including enable/disable state and strict column validation • **Rendition** - Defines how a renderer formats tables and contains the complete visual styling configuration • **Borders** - Control the outer frame visibility (top, bottom, left, right edges) of the table • **Lines** - Control horizontal boundary lines (above/below headers, above footers) that separate different table sections • **Separators** - Control the visibility of separators between rows and between columns within the table content • **Symbols** - Define the characters used for drawing table borders, corners, and junctions These components can be configured with various functional options when creating a new table. Examples Basic Examples • Simple Tables Create a basic table with headers and rows. default **Output**: with customization See symbols example for more • Markdown Table Generate a Markdown table for documentation. **Output**: • CSV Input Create a table from a CSV file with custom row alignment. **Output**: Advanced Examples • Colorized Table with Long Values Create a colorized table with wrapped long values, per-column colors, and a styled footer (inspired by and ). **Output** (colors visible in ANSI-compatible terminals): • Streaming Table with Truncation Stream a table incrementally with truncation and a footer, simulating a real-time data feed (inspired by and ). **Output** (appears incrementally): **Note**: Long descriptions are truncated with due to fixed column widths. The output appears row-by-row, simulating a real-time feed. • Hierarchical Merging for Organizational Data Show hierarchical merging for a tree-like structure, such as an organizational hierarchy (inspired by ). **Output**: **Note**: Hierarchical merging groups repeated values (e.g., "Engineering" spans multiple rows, "Backend" spans two teams), creating a tree-like structure. • Custom Padding with Merging Showcase custom padding and combined horizontal/vertical merging (inspired by in ). **Output**: • Nested Tables Create a table with nested sub-tables for complex layouts (inspired by in ). **Output**: • Structs with Database Render a table from a slice of structs, simulating a database query (inspired by in ). `go package main import ( "fmt" "github.com/olekukonko/tablewriter" "github.com/olekukonko/tablewriter/renderer" "github.com/olekukonko/tablewriter/tw" "os" ) type Employee struct { ID int Name string Age int Department string Salary float64 } func employeeStringer( _...truncated for preview_