alexeyco/simpletable
Tentang
Tabel sederhana di terminal dengan Go.
Alat pengembanganPertumbuhan bintang terukur
- dalam 24 jam
- +1
- dalam 7 hari
- +1
- dalam 15 hari
- 0
- dalam 1 bulan
- Mengumpulkan riwayat
Perubahan bersih pada periode yang tumpang tindih, bukan total harian. Pengukuran yang belum tersedia dibiarkan kosong. Bintang menunjukkan perhatian, bukan kualitas.
README.md
AsliSimple tables in terminal with Go
Build readable terminal tables in Go with seven built-in styles, multiline cells, alignment, and column spanning.
Comparison
✅ documented · ⚠️ partial · ❌ not found in sources checked. The last status means the sources checked did not document the feature; it does not establish that the library lacks it. Each symbol links to the public source checked for that comparison.
| Feature | simpletable | termtables | uitable | tablewriter | go-pretty |
|---|---|---|---|---|---|
| Multiline cell content | ✅ | ❌ | ⚠️ | ⚠️ | ❌ |
| Explicit column spans | ✅ | ✅ | ❌ | ⚠️ | ⚠️ |
| Markdown output | ✅ | ✅ | ❌ | ✅ | ✅ |
| Alignment controls | ✅ | ✅ | ⚠️ | ✅ | ✅ |
| Custom table styles | ✅ | ✅ | ❌ | ✅ | ✅ |
Sources checked on 2026-11-09. Add a library as a column or a feature as a row, and link each status to the public source checked.
Quick start
package main
import (
"fmt"
"strings"
"github.com/alexeyco/simpletable"
)
func main() {
table := simpletable.New()
table.Header = &simpletable.Header{
Cells: []*simpletable.Cell{
{Align: simpletable.AlignCenter, Text: "#"},
{Align: simpletable.AlignCenter, Text: "NAME"},
{Align: simpletable.AlignCenter, Text: "TAX"},
},
}
rows := []struct {
name string
tax float64
}{
{"Newton G. Goetz", 532.70},
{"Rebecca R. Edney", 1423.25},
{"John R. Jackson", 7526.12},
{"Ron J. Gomes", 123.84},
{"Penny R. Lewis", 3221.11},
}
total := 0.0
for i, row := range rows {
table.Body.Cells = append(table.Body.Cells, []*simpletable.Cell{
{Align: simpletable.AlignRight, Text: fmt.Sprintf("%d", i+1)},
{Text: row.name},
{Align: simpletable.AlignRight, Text: fmt.Sprintf("$ %.2f", row.tax)},
})
total += row.tax
}
table.Footer = &simpletable.Footer{
Cells: []*simpletable.Cell{
{Align: simpletable.AlignRight, Span: 2, Text: "Subtotal"},
{Align: simpletable.AlignRight, Text: fmt.Sprintf("$ %.2f", total)},
},
}
table.SetStyle(simpletable.StyleCompactLite)
for _, line := range strings.Split(table.String(), "\n") {
fmt.Println(strings.TrimPrefix(strings.TrimRight(line, " "), " "))
}
}
# NAME TAX
--- ------------------ ------------
1 Newton G. Goetz $ 532.70
2 Rebecca R. Edney $ 1423.25
3 John R. Jackson $ 7526.12
4 Ron J. Gomes $ 123.84
5 Penny R. Lewis $ 3221.11
--- ------------------ ------------
Subtotal $ 12827.02
Install with go get github.com/alexeyco/simpletable.
See the styles demo, multiline example, and column-span example for more.
Benchmarks
(MacBook)
Run these benchmarks using the benchmark instructions.
BenchmarkSimpletable-12 33529 35658 ns/op 31001 B/op 551 allocs/op
BenchmarkTermtables-12 34176 34871 ns/op 24255 B/op 755 allocs/op
BenchmarkUITable-12 6642 176902 ns/op 55212 B/op 2830 allocs/op
PASS
ok github.com/alexeyco/simpletable/_example/03-benchmarks-with-others/bench 4.978s
License
Jelajahi proyek terkait
Memuat…