Skip to content

Commit 2fd2a65

Browse files
committed
3rd - termtables
1 parent e646ba8 commit 2fd2a65

File tree

5 files changed

+55
-1
lines changed

5 files changed

+55
-1
lines changed

README.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -133,4 +133,6 @@
133133
* [dateparse](https://darjun.github.io/2021/06/24/godailylib/dateparse)
134134
日期时间字符串解析库。
135135
* [resty](https://darjun.github.io/2021/06/26/godailylib/resty)
136-
HTTP client。
136+
HTTP client。
137+
* [termtables](https://darjun.github.io/2021/06/29/godailylib/termtables/)
138+
控制台输出表格。

termtables/get-started/main.go

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
package main
2+
3+
import (
4+
"fmt"
5+
"github.com/scylladb/termtables"
6+
)
7+
8+
func main() {
9+
t := termtables.CreateTable()
10+
t.AddHeaders("User", "Age")
11+
t.AddRow("dj", 18)
12+
t.AddRow("darjun", 30)
13+
fmt.Println(t.Render())
14+
}

termtables/go.mod

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
module github.com/darjun/go-daily-lib/termtables
2+
3+
go 1.16
4+
5+
require (
6+
github.com/apcera/termtables v0.0.0-20170405184538-bcbc5dc54055 // indirect
7+
github.com/mattn/go-runewidth v0.0.13 // indirect
8+
github.com/scylladb/termtables v1.0.0 // indirect
9+
)

termtables/go.sum

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
github.com/apcera/termtables v0.0.0-20170405184538-bcbc5dc54055 h1:IkPAzP+QjchKXXFX6LCcpDKa89b/e/0gPCUbQGWtUUY=
2+
github.com/apcera/termtables v0.0.0-20170405184538-bcbc5dc54055/go.mod h1:8mHYHlOef9UC51cK1/WRvE/iQVM8O8QlYFa8eh8r5I8=
3+
github.com/mattn/go-runewidth v0.0.13 h1:lTGmDsbAYt5DmK6OnoV7EuIF1wEIFAcxld6ypU4OSgU=
4+
github.com/mattn/go-runewidth v0.0.13/go.mod h1:Jdepj2loyihRzMpdS35Xk/zdY8IAYHsh153qUoGf23w=
5+
github.com/rivo/uniseg v0.2.0 h1:S1pD9weZBuJdFmowNwbpi7BJ8TNftyUImj/0WQi72jY=
6+
github.com/rivo/uniseg v0.2.0/go.mod h1:J6wj4VEh+S6ZtnVlnTBMWIodfgj8LQOQFoIToxlJtxc=
7+
github.com/scylladb/termtables v1.0.0 h1:uUnesUY4V1VPCotpOQLb1LjTXVvzwy7Ramx8K8+w+8U=
8+
github.com/scylladb/termtables v1.0.0/go.mod h1:C1a7PQSMz9NShzorzCiG2fk9+xuCgLkPeCvMHYR2OWg=

termtables/markdown-html/main.go

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
package main
2+
3+
import (
4+
"fmt"
5+
6+
"github.com/scylladb/termtables"
7+
)
8+
9+
func main() {
10+
t := termtables.CreateTable()
11+
t.AddHeaders("User", "Age")
12+
t.AddRow("dj", 18)
13+
t.AddRow("darjun", 30)
14+
fmt.Println("HTML:")
15+
t.SetModeHTML()
16+
fmt.Println(t.Render())
17+
18+
fmt.Println("Markdown:")
19+
t.SetModeMarkdown()
20+
fmt.Println(t.Render())
21+
}

0 commit comments

Comments
 (0)