/
main.go
35 lines (28 loc) · 1.14 KB
/
main.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
package main
import (
"fmt"
"os"
"text/tabwriter"
"github.com/erikh/colorwriter"
"github.com/fatih/color"
)
func main() {
fmt.Println("This prints two tables with colors in them: the first is text/tabwriter, the second is colorwriter.")
fmt.Println("Outside of this, they are no different. Enjoy!")
fmt.Println()
fmt.Println("text/tabwriter")
fmt.Println()
tab := tabwriter.NewWriter(os.Stdout, 2, 2, 2, ' ', 0)
tab.Write([]byte("FOO\tBAR\tQUUX\n"))
tab.Write([]byte(fmt.Sprintf("%s\t%s\t%s\n", color.RedString("test"), color.BlueString("test2"), color.CyanString("blah"))))
tab.Write([]byte(fmt.Sprintf("%s\t%s\t%s\n", color.RedString("testing"), color.BlueString("test2 oh my"), color.CyanString("blah"))))
tab.Flush()
fmt.Println()
fmt.Println("colorwriter")
fmt.Println()
w := colorwriter.NewWriter(os.Stdout, 2, 2, 2, ' ', 0)
w.Write([]byte("FOO\tBAR\tQUUX\n"))
w.Write([]byte(fmt.Sprintf("%s\t%s\t%s\n", color.RedString("test"), color.BlueString("test2"), color.CyanString("blah"))))
w.Write([]byte(fmt.Sprintf("%s\t%s\t%s\n", color.RedString("testing"), color.BlueString("test2 oh my"), color.CyanString("blah"))))
w.Flush()
}