New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

github.com/tatsushid/go-prettytable

Package Overview
Dependencies
Alerts
File Explorer
Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

github.com/tatsushid/go-prettytable

  • v0.0.0-20141013043238-ed2d14c29939
  • Source
  • Go
  • Socket score

Version published
Created
Source

go-prettytable

go-prettytable is a library for Golang to build a simple text table with a multibyte, doublewidth character support.

GoDoc

Installation

Install and update this go package with go get -u github.com/tatsushid/go-prettytable

Examples

Import this package and use

tbl, err := prettytable.NewTable([]prettytable.Column{
	{Header: "COL1"},
	{Header: "COL2", MinWidth: 6},
	{Header: "COL3", AlignRight: true},
}...)
if err != nil {
	panic(err)
}
tbl.Separator = " | "
tbl.AddRow("foo", "bar", "baz")
tbl.AddRow(1, 2.3, 4)
tbl.Print()

It outputs

COL1 | COL2   | COL3
foo  | bar    |  baz
1    | 2.3    |    4

Also it can be used with multibyte, doublewidth characters

tbl, err := prettytable.NewTable([]prettytable.Column{
	{Header: "名前"},
	{Header: "個数", AlignRight: true},
}...)
if err != nil {
	panic(err)
}
tbl.Separator = " | "
tbl.AddRow("りんご", 5)
tbl.AddRow("みかん", 3)
tbl.AddRow("柿", 2)
tbl.Print()

It outputs (may not be displayed correctly with proportional fonts but it is displeyed good on terminal)

名前   | 個数
りんご |    5
みかん |    3
柿     |    2

For more detail, please see godoc.

See Also

License

go-prettytable is under MIT License. See the LICENSE file for details.

FAQs

Package last updated on 13 Oct 2014

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc