/
log.go
45 lines (41 loc) · 998 Bytes
/
log.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
package helpers
import (
"fmt"
"os"
"github.com/gugadev/cryptogo/models"
"github.com/olekukonko/tablewriter"
)
// Logger Util methods
type Logger struct{}
// Print print information about a coin
func (m *Logger) Print(coin models.Coin) {
fmt.Printf("\n✓ Currency information:\n\n")
data := [][]string{
[]string{
coin.Name,
coin.Symbol,
coin.Rank,
coin.PriceUSD,
coin.PriceEUR,
},
}
table := tablewriter.NewWriter(os.Stdout)
table.SetAlignment(1)
// table.SetBorder(false)
table.SetHeader([]string{
"Name",
"Symbol",
"Rank",
"USD Price",
"EUR Price",
})
table.SetHeaderColor(
tablewriter.Colors{tablewriter.Bold, tablewriter.BgGreenColor},
tablewriter.Colors{tablewriter.Bold, tablewriter.BgGreenColor},
tablewriter.Colors{tablewriter.Bold, tablewriter.BgGreenColor},
tablewriter.Colors{tablewriter.Bold, tablewriter.BgGreenColor},
tablewriter.Colors{tablewriter.Bold, tablewriter.BgGreenColor},
)
table.AppendBulk(data)
table.Render()
}