{"id":37126566,"url":"https://github.com/hchargois/flexwriter","last_synced_at":"2026-01-14T14:37:34.310Z","repository":{"id":273314286,"uuid":"919121185","full_name":"hchargois/flexwriter","owner":"hchargois","description":"Go package that arranges rows of data into columns with configurable widths and alignments","archived":false,"fork":false,"pushed_at":"2025-01-26T01:10:41.000Z","size":68,"stargazers_count":2,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-02-21T19:18:20.790Z","etag":null,"topics":["columns","flexbox","formatting","go","golang","table","text"],"latest_commit_sha":null,"homepage":"","language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/hchargois.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":"2025-01-19T18:54:18.000Z","updated_at":"2025-02-10T06:56:53.000Z","dependencies_parsed_at":"2025-01-20T06:44:34.849Z","dependency_job_id":"a6e3a0c4-37d8-4730-a5d7-8a1f6e614feb","html_url":"https://github.com/hchargois/flexwriter","commit_stats":null,"previous_names":["hchargois/flexwriter"],"tags_count":1,"template":false,"template_full_name":null,"purl":"pkg:github/hchargois/flexwriter","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hchargois%2Fflexwriter","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hchargois%2Fflexwriter/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hchargois%2Fflexwriter/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hchargois%2Fflexwriter/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/hchargois","download_url":"https://codeload.github.com/hchargois/flexwriter/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hchargois%2Fflexwriter/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28423956,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-01-14T13:30:50.153Z","status":"ssl_error","status_checked_at":"2026-01-14T13:29:08.907Z","response_time":107,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.5:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"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":["columns","flexbox","formatting","go","golang","table","text"],"created_at":"2026-01-14T14:37:33.608Z","updated_at":"2026-01-14T14:37:34.297Z","avatar_url":"https://github.com/hchargois.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Flexwriter\n\n[![Go Reference](https://pkg.go.dev/badge/github.com/hchargois/flexwriter.svg)](https://pkg.go.dev/github.com/hchargois/flexwriter)\n\n```\ngo get github.com/hchargois/flexwriter\n```\n\nFlexwriter arranges rows of data into columns with configurable widths and alignments.\n\nAs the name suggests, it implements the CSS flexbox model to define column widths.\n\nIf the contents are too long, flexwriter automatically wraps the text over multiple lines.\nText containing escape sequences (e.g. color codes) is correctly wrapped.\n\nThe output can be decorated with simple column separators or to look like tables.\n\n![demo screenshot showing features such as flexed columns, alignments and color support](demo.png)\n\n# Basic usage\n\n```go\nimport \"github.com/hchargois/flexwriter\"\n\n// by default, the flexwriter will output to standard output; and all\n// columns will default to being \"shrinkable\" columns (i.e. they will match\n// their content size if it fits within the output width, but will shrink to\n// match the output width if the content is too big to fit on a single line);\n// and all columns will be separated by two spaces\nwriter := flexwriter.New()\n\n// write some data (any non-string will pass through fmt.Sprint)\nwriter.WriteRow(\"deep\", \"thought\", \"says\", \":\")\nwriter.WriteRow(\"the\", \"answer\", \"is\", 42)\nwriter.WriteRow(true, \"or\", false, \"?\")\n\n// calling Flush() is required to actually output the rows\nwriter.Flush()\n```\n\nThis will output:\n\n```\ndeep  thought  says   :\nthe   answer   is     42\ntrue  or       false  ?\n```\n\nHere's another example showing how to configure the columns and set a table\ndecorator, and that shows how the Shrinkable columns shrinks to fit in the\nconfigured width of the output (70 columns wide):\n\n```go\nwriter := flexwriter.New()\nwriter.SetColumns(\n    // first column, a Rigid, will not shrink and wrap\n    flexwriter.Rigid{},\n    // second column will\n    flexwriter.Shrinkable{})\nwriter.SetDecorator(flexwriter.AsciiTableDecorator())\nwriter.SetWidth(70)\n\nlorem := \"Lorem ipsum dolor sit amet, consectetur adipiscing elit, \"+\n\"sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim \"+\n\"ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip\"\n\nwriter.WriteRow(\"lorem ipsum says:\", lorem)\n\nwriter.Flush()\n```\n\nThis outputs:\n\n```\n+-------------------+------------------------------------------------+\n| lorem ipsum says: | Lorem ipsum dolor sit amet, consectetur        |\n|                   | adipiscing elit, sed do eiusmod tempor         |\n|                   | incididunt ut labore et dolore magna aliqua.   |\n|                   | Ut enim ad minim veniam, quis nostrud          |\n|                   | exercitation ullamco laboris nisi ut aliquip   |\n+-------------------+------------------------------------------------+\n```\n\nMany more examples can be found in the [godoc](https://pkg.go.dev/github.com/hchargois/flexwriter).\n\n# Alternatives\n\n - the OG, standard library's [text/tabwriter](https://pkg.go.dev/text/tabwriter)\n - for a more full-fledged table writer, see [github.com/olekukonko/tablewriter](https://github.com/olekukonko/tablewriter)\n   but note that as of Jan 2025 it doesn't correctly handle wrapping text\n   with escape strings.\n\n# Thanks\n\n - [Gio UI](https://gioui.org) for the initial inspiration to use the [flex model](https://pkg.go.dev/gioui.org/layout#Flex)\n - [github.com/MichaelMure/go-term-text](https://github.com/MichaelMure/go-term-text) for the escape-sequence aware text wrapping\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhchargois%2Fflexwriter","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fhchargois%2Fflexwriter","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhchargois%2Fflexwriter/lists"}