Utilities to prettify console output of tables, lists, progress-bars, text, etc. with a heavy emphasis on customization.
The current major version of this package is v6, and it follows the standard outlined here.
Run go get github.com/jedib0t/go-pretty/v6 to add this as a dependency to your
project, and import the packages in your code using one or more of these:
github.com/jedib0t/go-pretty/v6/listgithub.com/jedib0t/go-pretty/v6/progressgithub.com/jedib0t/go-pretty/v6/tablegithub.com/jedib0t/go-pretty/v6/text
Pretty-print tables in a terminal with colors, nested tables and more.
+-----+------------+-----------+--------+-----------------------------+
| # | FIRST NAME | LAST NAME | SALARY | |
+-----+------------+-----------+--------+-----------------------------+
| 1 | Arya | Stark | 3000 | |
| 20 | Jon | Snow | 2000 | You know nothing, Jon Snow! |
| 300 | Tyrion | Lannister | 5000 | |
+-----+------------+-----------+--------+-----------------------------+
| | | TOTAL | 10000 | |
+-----+------------+-----------+--------+-----------------------------+
Execute go run github.com/jedib0t/go-pretty/v6/cmd/demo-table@latest colors to get:
More details can be found here: table/
Track the Progress of one or more Tasks like downloading multiple files in parallel.
More details can be found here: progress/
Pretty-print lists with multiple levels/indents into ASCII/Unicode strings.
╭─ Game Of Thrones
│ ├─ Winter
│ ├─ Is
│ ╰─ Coming
│ ├─ This
│ ├─ Is
│ ╰─ Known
╰─ The Dark Tower
╰─ The Gunslinger
More details can be found here: list/
Utility functions to manipulate text with or without ANSI escape sequences. Most of the functions available are used in one or more of the other packages here.
- Align text Horizontally or Vertically
- Colorize text
- Move cursor
- Format text (convert case)
- Manipulate strings (Pad, RepeatAndTrim, RuneCount, etc.)
- Transform text (UnixTime to human-readable-time, pretty-JSON, etc.)
- Wrap text
GoDoc has examples for all the available functions.
If you are using a version of this library older than v6.0.0 and want to move
to a newer version of this library, you'd have to modify the import paths from
something like:
"github.com/jedib0t/go-pretty/list"
"github.com/jedib0t/go-pretty/progress"
"github.com/jedib0t/go-pretty/table"
"github.com/jedib0t/go-pretty/text"to:
"github.com/jedib0t/go-pretty/v6/list"
"github.com/jedib0t/go-pretty/v6/progress"
"github.com/jedib0t/go-pretty/v6/table"
"github.com/jedib0t/go-pretty/v6/text"I'd recommend you fire up your favorite IDE and do a mass search and replace for
all occurrences of jedib0t/go-pretty/ to jedib0t/go-pretty/v6/. If you are
on a system with access to find, grep, xargs and sed, you could just run
the following from within your code folder to do the same:
find . -type f -name "*.go" | grep -v vendor | xargs sed -i 's/jedib0t\/go-pretty\//jedib0t\/go-pretty\/v6\//g'
If you are on macOS, you'll have to use sed -i '' instead of sed -i.