NewTable is the constructor function creating a new printable table from a list of headers. The table is also connected to a UI, which is where it will print itself to on demand.
(headers []string)
| 30 | // from a list of headers. The table is also connected to a UI, which |
| 31 | // is where it will print itself to on demand. |
| 32 | func NewTable(headers []string) *Table { |
| 33 | pt := &Table{ |
| 34 | headers: headers, |
| 35 | columnWidth: make([]int, len(headers)), |
| 36 | colSpacing: " ", |
| 37 | transformer: make([]Transformer, len(headers)), |
| 38 | } |
| 39 | // Standard colorization, column 0 is auto-highlighted as some |
| 40 | // name. Everything else has no transformation (== identity |
| 41 | // transform) |
| 42 | for i := range pt.transformer { |
| 43 | pt.transformer[i] = nop |
| 44 | } |
| 45 | if 0 < len(headers) { |
| 46 | pt.transformer[0] = TableContentHeaderColor |
| 47 | } |
| 48 | return pt |
| 49 | } |
| 50 | |
| 51 | // NoHeaders disables the printing of the header row for the specified |
| 52 | // table. |
no outgoing calls
no test coverage detected