| | |
| | |
| | |
| |
|
| | package tabwriter_test |
| |
|
| | import ( |
| | "fmt" |
| | "os" |
| | "text/tabwriter" |
| | ) |
| |
|
| | func ExampleWriter_Init() { |
| | w := new(tabwriter.Writer) |
| |
|
| | |
| | w.Init(os.Stdout, 0, 8, 0, '\t', 0) |
| | fmt.Fprintln(w, "a\tb\tc\td\t.") |
| | fmt.Fprintln(w, "123\t12345\t1234567\t123456789\t.") |
| | fmt.Fprintln(w) |
| | w.Flush() |
| |
|
| | |
| | |
| | |
| | w.Init(os.Stdout, 5, 0, 1, ' ', tabwriter.AlignRight) |
| | fmt.Fprintln(w, "a\tb\tc\td\t.") |
| | fmt.Fprintln(w, "123\t12345\t1234567\t123456789\t.") |
| | fmt.Fprintln(w) |
| | w.Flush() |
| |
|
| | |
| | |
| | |
| | |
| | |
| | |
| | } |
| |
|
| | func Example_elastic() { |
| | |
| | |
| | w := tabwriter.NewWriter(os.Stdout, 0, 0, 1, '.', tabwriter.AlignRight|tabwriter.Debug) |
| | fmt.Fprintln(w, "a\tb\tc") |
| | fmt.Fprintln(w, "aa\tbb\tcc") |
| | fmt.Fprintln(w, "aaa\t") |
| | fmt.Fprintln(w, "aaaa\tdddd\teeee") |
| | w.Flush() |
| |
|
| | |
| | |
| | |
| | |
| | |
| | } |
| |
|
| | func Example_trailingTab() { |
| | |
| | |
| | const padding = 3 |
| | w := tabwriter.NewWriter(os.Stdout, 0, 0, padding, '-', tabwriter.AlignRight|tabwriter.Debug) |
| | fmt.Fprintln(w, "a\tb\taligned\t") |
| | fmt.Fprintln(w, "aa\tbb\taligned\t") |
| | fmt.Fprintln(w, "aaa\tbbb\tunaligned") |
| | fmt.Fprintln(w, "aaaa\tbbbb\taligned\t") |
| | w.Flush() |
| |
|
| | |
| | |
| | |
| | |
| | |
| | } |
| |
|