Documentation ¶
Index ¶
Examples ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type TablePrinter ¶
type TablePrinter struct { DittoMark string SingleRowTranspose bool NoPrintRowSeq bool TagName string }
TablePrinter ...
Example ¶
package main import ( "fmt" "github.com/bingoohuang/prettytable" ) type Person struct { FirstName string `table:"FIRST"` LastName string Salary int Words string Address string `table:"-"` } func main() { persons := []Person{ {FirstName: "Arya", LastName: "Stark", Salary: 3000, Words: ""}, {FirstName: "Jon", LastName: "Snow", Salary: 2000, Words: "You know nothing, Jon Snow!"}, {FirstName: "Tyrion", LastName: "Lannister", Salary: 5000, Words: ""}, } out := prettytable.TablePrinter{}.Print(&persons) fmt.Println(out) }
Output: ┌───┬────────┬───────────┬────────┬─────────────────────────────┐ │ # │ FIRST │ LAST NAME │ SALARY │ WORDS │ ├───┼────────┼───────────┼────────┼─────────────────────────────┤ │ 1 │ Arya │ Stark │ 3000 │ │ │ 2 │ Jon │ Snow │ 2000 │ You know nothing, Jon Snow! │ │ 3 │ Tyrion │ Lannister │ 5000 │ │ └───┴────────┴───────────┴────────┴─────────────────────────────┘
func (TablePrinter) Print ¶
func (p TablePrinter) Print(value interface{}) string
Click to show internal directories.
Click to hide internal directories.