-
Notifications
You must be signed in to change notification settings - Fork 31
/
Copy pathmain.go
53 lines (45 loc) · 1.41 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
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
package main
import (
"fmt"
"github.com/fatih/color"
"github.com/gosuri/uitable"
)
type hacker struct {
Name, Birthday, Bio string
}
var hackers = []hacker{
{"Ada Lovelace", "December 10, 1815", "Ada was a British mathematician and writer, chiefly known for her work on Charles Babbage's early mechanical general-purpose computer, the Analytical Engine"},
{"Alan Turing", "June 23, 1912", "Alan was a British pioneering computer scientist, mathematician, logician, cryptanalyst and theoretical biologist"},
}
func main() {
table := uitable.New()
table.MaxColWidth = 50
fmt.Println("==> List")
table.AddRow("NAME", "BIRTHDAY", "BIO")
for _, hacker := range hackers {
table.AddRow(hacker.Name, hacker.Birthday, hacker.Bio)
}
fmt.Println(table)
fmt.Print("\n==> Details\n")
table = uitable.New()
table.MaxColWidth = 80
table.Wrap = true
for _, hacker := range hackers {
table.AddRow("Name:", hacker.Name)
table.AddRow("Birthday:", hacker.Birthday)
table.AddRow("Bio:", hacker.Bio)
table.AddRow("") // blank
}
fmt.Println(table)
fmt.Print("\n==> Multicolor Support\n")
table = uitable.New()
table.MaxColWidth = 80
table.Wrap = true
for _, hacker := range hackers {
table.AddRow(color.RedString("Name:"), color.WhiteString(hacker.Name))
table.AddRow(color.BlueString("Birthday:"), hacker.Birthday)
table.AddRow(color.GreenString("Bio:"), hacker.Bio)
table.AddRow("") // blank
}
fmt.Println(table)
}