Go Package text/tabwriter: Difference between revisions
Jump to navigation
Jump to search
Line 7: | Line 7: | ||
=Overview= | =Overview= | ||
The package implements a write filter that translates tabbed columns in input into properly aligned text. The package is using the Elastic Tabstops algorithm described at http://nickgravgaard.com/elastictabstops/index.html. | The package implements a write filter that translates tabbed columns in input into properly aligned text. The package is using the Elastic Tabstops algorithm described at http://nickgravgaard.com/elastictabstops/index.html. | ||
<syntaxhighlight lang='go'> | |||
tw := tabwriter.NewWriter(os.Stdout, 0, 1, 2, ' ', 0) | |||
defer tw.Flush() | |||
fmt.Fprintf(tw, "Column A\tColumn B\tColumn C\n") | |||
fmt.Fprintf(tw, "a\tbbbbbb\tccc\n") | |||
fmt.Fprintf(tw, "aaaa\tbb\tccc\n") | |||
fmt.Fprintf(tw, "aaaaaaaaaaaaa\tb\tcccc\n") | |||
</syntaxhighlight> |
Revision as of 04:04, 20 January 2024
External
Internal
Overview
The package implements a write filter that translates tabbed columns in input into properly aligned text. The package is using the Elastic Tabstops algorithm described at http://nickgravgaard.com/elastictabstops/index.html.
tw := tabwriter.NewWriter(os.Stdout, 0, 1, 2, ' ', 0)
defer tw.Flush()
fmt.Fprintf(tw, "Column A\tColumn B\tColumn C\n")
fmt.Fprintf(tw, "a\tbbbbbb\tccc\n")
fmt.Fprintf(tw, "aaaa\tbb\tccc\n")
fmt.Fprintf(tw, "aaaaaaaaaaaaa\tb\tcccc\n")