go-pretty

module
v4.0.2+incompatible Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 10, 2018 License: MIT

README

go-pretty

Build Status Coverage Status Go Report Card GoDoc

Utilities to prettify console output of tables, lists, text, etc.

Table

Pretty-print tables into ASCII/Unicode strings.

+-----+------------+-----------+--------+-----------------------------+
|   # | FIRST NAME | LAST NAME | SALARY |                             |
+-----+------------+-----------+--------+-----------------------------+
|   1 | Arya       | Stark     |   3000 |                             |
|  20 | Jon        | Snow      |   2000 | You know nothing, Jon Snow! |
| 300 | Tyrion     | Lannister |   5000 |                             |
+-----+------------+-----------+--------+-----------------------------+
|     |            | TOTAL     |  10000 |                             |
+-----+------------+-----------+--------+-----------------------------+

Detailed documentation can be found here: table/

List

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

Detailed documentation can be found here: list/

Progress

Track the Progress of one or more Tasks (like downloading multiple files in parallel).

Sample Progress Tracking:

Calculating Total   #  1 ... done! [3.25K in 100ms]
Calculating Total   #  2 ... done! [6.50K in 100ms]
Downloading File    #  3 ... done! [9.75KB in 100ms]
Transferring Amount #  4 ... done! [$26.00K in 200ms]
Transferring Amount #  5 ... done! [£32.50K in 201ms]
Downloading File    #  6 ... done! [58.50KB in 300ms]
Calculating Total   #  7 ... done! [91.00K in 400ms]
Transferring Amount #  8 ... 60.9% (●●●●●●●●●●●●●●◌◌◌◌◌◌◌◌◌) [$78.00K in 399.071ms]
Downloading File    #  9 ... 32.1% (●●●●●●●○◌◌◌◌◌◌◌◌◌◌◌◌◌◌◌) [58.50KB in 298.947ms]
Transferring Amount # 10 ... 13.0% (●●○◌◌◌◌◌◌◌◌◌◌◌◌◌◌◌◌◌◌◌◌) [£32.50K in 198.84ms]

Detailed documentation can be found here: progress/

Text

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.

The unit-tests for each of the above show how these can be used. There GoDoc should also have examples for all the available functions.

Benchmarks

Partial output of make bench:

BenchmarkList_Render-24             	  200000	      5073 ns/op	     872 B/op	      47 allocs/op
BenchmarkProgress_Render-24         	       5	 300373700 ns/op	    4728 B/op	      91 allocs/op
BenchmarkTable_Render-24            	   30000	     42402 ns/op	    5701 B/op	     193 allocs/op
BenchmarkTable_RenderCSV-24         	  200000	     11874 ns/op	    2626 B/op	      50 allocs/op
BenchmarkTable_RenderHTML-24        	  100000	     17338 ns/op	    4083 B/op	      49 allocs/op
BenchmarkTable_RenderMarkdown-24    	  200000	     11924 ns/op	    2562 B/op	      48 allocs/op

Directories

Path Synopsis
cmd

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL