| 1 |
package main |
| 2 |
|
| 3 |
import ( |
| 4 |
"fmt" |
| 5 |
"os" |
| 6 |
|
| 7 |
"github.com/olekukonko/ll" |
| 8 |
"github.com/olekukonko/tablewriter" |
| 9 |
"github.com/olekukonko/tablewriter/renderer" |
| 10 |
"github.com/olekukonko/tablewriter/tw" |
| 11 |
) |
| 12 |
|
| 13 |
func main() { |
| 14 |
data := [][]string{ |
| 15 |
{"Engineering", "Backend", "API Team", "Alice"}, |
| 16 |
{"Engineering", "Backend", "Database Team", "Bob"}, |
| 17 |
{"Engineering", "Frontend", "UI Team", "Charlie"}, |
| 18 |
{"Marketing", "Digital", "SEO Team", "Dave"}, |
| 19 |
{"Marketing", "Digital", "Content Team", "Eve"}, |
| 20 |
} |
| 21 |
|
| 22 |
cnf := tablewriter.Config{ |
| 23 |
Header: tw.CellConfig{ |
| 24 |
Alignment: tw.CellAlignment{Global: tw.AlignCenter}, |
| 25 |
}, |
| 26 |
Row: tw.CellConfig{ |
| 27 |
Merging: tw.CellMerging{Mode: tw.MergeHierarchical}, |
| 28 |
Alignment: tw.CellAlignment{Global: tw.AlignLeft}, |
| 29 |
}, |
| 30 |
Debug: false, |
| 31 |
} |
| 32 |
|
| 33 |
// Create a custom border style |
| 34 |
DottedStyle := []tw.Symbols{ |
| 35 |
tw.NewSymbolCustom("Dotted"). |
| 36 |
WithRow("·"). |
| 37 |
WithColumn(":"). |
| 38 |
WithTopLeft("."). |
| 39 |
WithTopMid("·"). |
| 40 |
WithTopRight("."). |
| 41 |
WithMidLeft(":"). |
| 42 |
WithCenter("+"). |
| 43 |
WithMidRight(":"). |
| 44 |
WithBottomLeft("'"). |
| 45 |
WithBottomMid("·"). |
| 46 |
WithBottomRight("'"), |
| 47 |
|
| 48 |
// arrow style |
| 49 |
tw.NewSymbolCustom("Arrow"). |
| 50 |
WithRow("→"). |
| 51 |
WithColumn("↓"). |
| 52 |
WithTopLeft("↗"). |
| 53 |
WithTopMid("↑"). |
| 54 |
WithTopRight("↖"). |
| 55 |
WithMidLeft("→"). |
| 56 |
WithCenter("↔"). |
| 57 |
WithMidRight("←"). |
| 58 |
WithBottomLeft("↘"). |
| 59 |
WithBottomMid("↓"). |
| 60 |
WithBottomRight("↙"), |
| 61 |
|
| 62 |
// start style |
| 63 |
tw.NewSymbolCustom("Starry"). |
| 64 |
WithRow("★"). |
| 65 |
WithColumn("☆"). |
| 66 |
WithTopLeft("✧"). |
| 67 |
WithTopMid("✯"). |
| 68 |
WithTopRight("✧"). |
| 69 |
WithMidLeft("✦"). |
| 70 |
WithCenter("✶"). |
| 71 |
WithMidRight("✦"). |
| 72 |
WithBottomLeft("✧"). |
| 73 |
WithBottomMid("✯"). |
| 74 |
WithBottomRight("✧"), |
| 75 |
|
| 76 |
tw.NewSymbolCustom("Hearts"). |
| 77 |
WithRow("♥"). |
| 78 |
WithColumn("❤"). |
| 79 |
WithTopLeft("❥"). |
| 80 |
WithTopMid("♡"). |
| 81 |
WithTopRight("❥"). |
| 82 |
WithMidLeft("❣"). |
| 83 |
WithCenter("✚"). |
| 84 |
WithMidRight("❣"). |
| 85 |
WithBottomLeft("❦"). |
| 86 |
WithBottomMid("♡"). |
| 87 |
WithBottomRight("❦"), |
| 88 |
|
| 89 |
tw.NewSymbolCustom("Tech"). |
| 90 |
WithRow("="). |
| 91 |
WithColumn("||"). |
| 92 |
WithTopLeft("/*"). |
| 93 |
WithTopMid("##"). |
| 94 |
WithTopRight("*/"). |
| 95 |
WithMidLeft("//"). |
| 96 |
WithCenter("<>"). |
| 97 |
WithMidRight("\\"). |
| 98 |
WithBottomLeft("\\*"). |
| 99 |
WithBottomMid("##"). |
| 100 |
WithBottomRight("*/"), |
| 101 |
|
| 102 |
tw.NewSymbolCustom("Nature"). |
| 103 |
WithRow("~"). |
| 104 |
WithColumn("|"). |
| 105 |
WithTopLeft("🌱"). |
| 106 |
WithTopMid("🌿"). |
| 107 |
WithTopRight("🌱"). |
| 108 |
WithMidLeft("🍃"). |
| 109 |
WithCenter("❀"). |
| 110 |
WithMidRight("🍃"). |
| 111 |
WithBottomLeft("🌻"). |
| 112 |
WithBottomMid("🌾"). |
| 113 |
WithBottomRight("🌻"), |
| 114 |
|
| 115 |
tw.NewSymbolCustom("Artistic"). |
| 116 |
WithRow("▬"). |
| 117 |
WithColumn("▐"). |
| 118 |
WithTopLeft("◈"). |
| 119 |
WithTopMid("◊"). |
| 120 |
WithTopRight("◈"). |
| 121 |
WithMidLeft("◀"). |
| 122 |
WithCenter("⬔"). |
| 123 |
WithMidRight("▶"). |
| 124 |
WithBottomLeft("◭"). |
| 125 |
WithBottomMid("▣"). |
| 126 |
WithBottomRight("◮"), |
| 127 |
|
| 128 |
tw.NewSymbolCustom("8-Bit"). |
| 129 |
WithRow("■"). |
| 130 |
WithColumn("█"). |
| 131 |
WithTopLeft("╔"). |
| 132 |
WithTopMid("▲"). |
| 133 |
WithTopRight("╗"). |
| 134 |
WithMidLeft("◄"). |
| 135 |
WithCenter("♦"). |
| 136 |
WithMidRight("►"). |
| 137 |
WithBottomLeft("╚"). |
| 138 |
WithBottomMid("▼"). |
| 139 |
WithBottomRight("╝"), |
| 140 |
|
| 141 |
tw.NewSymbolCustom("Chaos"). |
| 142 |
WithRow("≈"). |
| 143 |
WithColumn("§"). |
| 144 |
WithTopLeft("⌘"). |
| 145 |
WithTopMid("∞"). |
| 146 |
WithTopRight("⌥"). |
| 147 |
WithMidLeft("⚡"). |
| 148 |
WithCenter("☯"). |
| 149 |
WithMidRight("♞"). |
| 150 |
WithBottomLeft("⌂"). |
| 151 |
WithBottomMid("∆"). |
| 152 |
WithBottomRight("◊"), |
| 153 |
|
| 154 |
tw.NewSymbolCustom("Dots"). |
| 155 |
WithRow("·"). |
| 156 |
WithColumn(" "). // Invisible column lines |
| 157 |
WithTopLeft("·"). |
| 158 |
WithTopMid("·"). |
| 159 |
WithTopRight("·"). |
| 160 |
WithMidLeft(" "). |
| 161 |
WithCenter("·"). |
| 162 |
WithMidRight(" "). |
| 163 |
WithBottomLeft("·"). |
| 164 |
WithBottomMid("·"). |
| 165 |
WithBottomRight("·"), |
| 166 |
|
| 167 |
tw.NewSymbolCustom("Blocks"). |
| 168 |
WithRow("▀"). |
| 169 |
WithColumn("█"). |
| 170 |
WithTopLeft("▛"). |
| 171 |
WithTopMid("▀"). |
| 172 |
WithTopRight("▜"). |
| 173 |
WithMidLeft("▌"). |
| 174 |
WithCenter("█"). |
| 175 |
WithMidRight("▐"). |
| 176 |
WithBottomLeft("▙"). |
| 177 |
WithBottomMid("▄"). |
| 178 |
WithBottomRight("▟"), |
| 179 |
|
| 180 |
tw.NewSymbolCustom("Zen"). |
| 181 |
WithRow("~"). |
| 182 |
WithColumn(" "). |
| 183 |
WithTopLeft(" "). |
| 184 |
WithTopMid("♨"). |
| 185 |
WithTopRight(" "). |
| 186 |
WithMidLeft(" "). |
| 187 |
WithCenter("☯"). |
| 188 |
WithMidRight(" "). |
| 189 |
WithBottomLeft(" "). |
| 190 |
WithBottomMid("♨"). |
| 191 |
WithBottomRight(" "), |
| 192 |
} |
| 193 |
|
| 194 |
var table *tablewriter.Table |
| 195 |
for _, style := range DottedStyle { |
| 196 |
ll.Info(style.Name() + " style") |
| 197 |
table = tablewriter.NewTable(os.Stdout, |
| 198 |
tablewriter.WithRenderer(renderer.NewBlueprint(tw.Rendition{Symbols: style})), |
| 199 |
tablewriter.WithConfig(cnf), |
| 200 |
) |
| 201 |
table.Header([]string{"Department", "Division", "Team", "Lead"}) |
| 202 |
table.Bulk(data) |
| 203 |
table.Render() |
| 204 |
|
| 205 |
fmt.Println() |
| 206 |
} |
| 207 |
} |