{"id":17661638,"url":"https://github.com/djthorpe/go-tablewriter","last_synced_at":"2025-03-30T11:22:28.645Z","repository":{"id":238645413,"uuid":"797083885","full_name":"djthorpe/go-tablewriter","owner":"djthorpe","description":"Writer for table data","archived":false,"fork":false,"pushed_at":"2024-05-23T07:02:01.000Z","size":70,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2024-05-23T07:29:27.789Z","etag":null,"topics":["ascii","csv","golang","tablewriter","tsv"],"latest_commit_sha":null,"homepage":"https://pkg.go.dev/github.com/djthorpe/go-tablewriter","language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/djthorpe.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2024-05-07T07:00:42.000Z","updated_at":"2024-06-18T07:49:29.165Z","dependencies_parsed_at":"2024-06-18T07:49:26.973Z","dependency_job_id":"26d583b6-d617-4cd3-af66-a0b8a4693c73","html_url":"https://github.com/djthorpe/go-tablewriter","commit_stats":null,"previous_names":["djthorpe/go-tablewriter"],"tags_count":8,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/djthorpe%2Fgo-tablewriter","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/djthorpe%2Fgo-tablewriter/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/djthorpe%2Fgo-tablewriter/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/djthorpe%2Fgo-tablewriter/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/djthorpe","download_url":"https://codeload.github.com/djthorpe/go-tablewriter/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":246309402,"owners_count":20756708,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["ascii","csv","golang","tablewriter","tsv"],"created_at":"2024-10-23T17:22:43.842Z","updated_at":"2025-03-30T11:22:28.612Z","avatar_url":"https://github.com/djthorpe.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# go-tablewriter\n\nThis module implements a writer for table data, which can be output as CSV or Text.\n\nExample:\n\n```go\npackage main\n\nimport (\n    tablewriter \"github.com/djthorpe/go-tablewriter\"\n\n)\n\nfunc main() {\n  table := []TableData{\n    {A: \"hello\", B: \"world\"},\n  }\n  writer := tablewriter.New(os.Stdout)\n  writer.Write(table, tablewriter.OptHeader())\n}\n```\n\nThe `Write` function expects a single struct or a slice of structs as the first argument. Each struct\nrepresents a row in the table. The struct fields (including any which are embedded) are used as\ncolumns in the table.\n\n## Table Options\n\nThe following options can be used to customize the output:\n\n- `tablewriter.OptHeader()`: Output the header row.\n- `tablewriter.OptFieldDelim('|')`: Set the field delimiter, default is ',' for CSV and '|' for Text.\n- `tablewriter.OptOutputCSV()`: Output as CSV.\n- `tablewriter.OptOutputText()`: Output as Text.\n- `tablewriter.OptNull(\"\u003cnil\u003e\")`: Set how the nil value is represented in the output, defaults to `\u003cnil\u003e`.\n\n## Struct Tags\n\nTags on struct fields can determine how the field is output. The `json` and `writer` tags can be used,\nwith the `writer` tag options taking precedence.\n\n- `writer:\"-\"`: Skip the field.\n- `writer:\"Name\"`: Set the column header to \"Name\".\n- `writer:\",omitdefault\"`: If all values in the table are zero-valued, skip output of the column (TODO)\n- `writer:\",wrap\"`: Field is wrapped to the width of the column.\n- `writer:\",alignright\"`: Field is right-aligned in the column.\n- `writer:\",width:20\"`: Suggested column width is 20 characters\n\n## Customize Field Output\n\nYou can implement the following interface on any field to customize how it is output:\n\n```go\ntype Marshaller interface {\n  Marshal() ([]byte, error)\n}\n```\n\nBy default, strings and time.Time types are output as-is and other values are marshalled\nusing the `encoding/json` package.\n\n## Contribution and License\n\nSee the [LICENSE](LICENSE) file for license rights and limitations, currently Apache.\nPull requests and [issues](https://github.com/djthorpe/go-tablewriter/issues) are welcome.\n\n## Changelog\n\n- v0.0.1 (May 2024) Initial version\n- v0.0.2 (May 2024) Documentation updates\n- v0.0.4 (May 2024) Added text wrapping for text output\n- v0.0.5 (May 2024) Exposing options for customizing the output in the struct tags\n- v0.0.9 (Aug 2024) Added a `Writeln` method for output of text\n- v0.0.10 (Dec 2024) Upgraded dependencies\n\nFuture versions will include more options for customizing the output:\n\n- Estimating sizing the width of fields for the text package\n- Setting the width of the table based on terminal width\n- Adding JSON and SQL output\n- Outputing fields with ANSI color codes\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdjthorpe%2Fgo-tablewriter","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdjthorpe%2Fgo-tablewriter","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdjthorpe%2Fgo-tablewriter/lists"}