ProductPromotion
Logo

Go.Lang

made by https://0x3d.site

GitHub - tomlazar/table: pretty colorfull tables in go with less effort
pretty colorfull tables in go with less effort. Contribute to tomlazar/table development by creating an account on GitHub.
Visit Site

GitHub - tomlazar/table: pretty colorfull tables in go with less effort

GitHub - tomlazar/table: pretty colorfull tables in go with less effort

Table

Go codecov GoDoc Go Report Card FOSSA Status

Print out tabular data on the command line using the ansi color esacape codes. Support for writing the ouput based on the fields in a struct and for defining and creating the table manully using the underlying object.

Support for colors on windows can be don using mattn/go-colorable to make a io.Writer that will work.

Usage

For creating a table yourself using the struct.

	tab := table.Table{
		Headers: []string{"something", "another"},
		Rows: [][]string{
			{"1", "2"},
			{"3", "4"},
			{"3", "a longer piece of text that should stretch"},
			{"but this one is longer", "shorter now"},
		},
	}
	err := tab.WriteTable(w, nil) // w is any io.Writer

simple example

With a struct slice

	data := []struct {
		Name     string `table:"THE NAME"`
		Location string `table:"THE LOCATION"`
	}{
		{"name", "l"},
		{"namgfcxe", "asfdad"},
		{"namr3e", "l134151dsa"},
		{"namear", "lasd2135"},
	}

    err := table.MarshalTo(w, data, nil) // writes to any w = io.Writer
    buf, err := table.Marshal(data, nil) // also supports return the bytes

reflection

The nil parameter is the configuration for the table, this can be set manually, but if its left as nil the deafult config settings will be used.

type Config struct {
	ShowIndex       bool     // shows the index/row number as the first column
	Color           bool     // use the color codes in the output
	AlternateColors bool     // alternate the colors when writing
	TitleColorCode  string   // the ansi code for the title row
	AltColorCodes   []string // the ansi codes to alternate between
}

Installation

Go makes this part easy.

$ go get github.com/mattn/go-colorable

License

MIT

FOSSA Status

Author

Tom Lazar

Articles
to learn more about the golang concepts.

Resources
which are currently available to browse on.

mail [email protected] to add your project or resources here ๐Ÿ”ฅ.

FAQ's
to know more about the topic.

mail [email protected] to add your project or resources here ๐Ÿ”ฅ.

Queries
or most google FAQ's about GoLang.

mail [email protected] to add more queries here ๐Ÿ”.

More Sites
to check out once you're finished browsing here.

0x3d
https://www.0x3d.site/
0x3d is designed for aggregating information.
NodeJS
https://nodejs.0x3d.site/
NodeJS Online Directory
Cross Platform
https://cross-platform.0x3d.site/
Cross Platform Online Directory
Open Source
https://open-source.0x3d.site/
Open Source Online Directory
Analytics
https://analytics.0x3d.site/
Analytics Online Directory
JavaScript
https://javascript.0x3d.site/
JavaScript Online Directory
GoLang
https://golang.0x3d.site/
GoLang Online Directory
Python
https://python.0x3d.site/
Python Online Directory
Swift
https://swift.0x3d.site/
Swift Online Directory
Rust
https://rust.0x3d.site/
Rust Online Directory
Scala
https://scala.0x3d.site/
Scala Online Directory
Ruby
https://ruby.0x3d.site/
Ruby Online Directory
Clojure
https://clojure.0x3d.site/
Clojure Online Directory
Elixir
https://elixir.0x3d.site/
Elixir Online Directory
Elm
https://elm.0x3d.site/
Elm Online Directory
Lua
https://lua.0x3d.site/
Lua Online Directory
C Programming
https://c-programming.0x3d.site/
C Programming Online Directory
C++ Programming
https://cpp-programming.0x3d.site/
C++ Programming Online Directory
R Programming
https://r-programming.0x3d.site/
R Programming Online Directory
Perl
https://perl.0x3d.site/
Perl Online Directory
Java
https://java.0x3d.site/
Java Online Directory
Kotlin
https://kotlin.0x3d.site/
Kotlin Online Directory
PHP
https://php.0x3d.site/
PHP Online Directory
React JS
https://react.0x3d.site/
React JS Online Directory
Angular
https://angular.0x3d.site/
Angular JS Online Directory