-
Notifications
You must be signed in to change notification settings - Fork 128
/
color.go
55 lines (51 loc) · 1.48 KB
/
color.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
46
47
48
49
50
51
52
53
54
55
package print
import (
"sync"
"github.com/fatih/color"
)
var (
// mu is used to synchronize writes from multiple goroutines.
mu sync.Mutex
createPrintf = color.New(color.FgGreen).PrintfFunc()
// CreatePrintf is fmt.Printf with red as foreground color.
CreatePrintf = func(format string, a ...interface{}) {
mu.Lock()
defer mu.Unlock()
createPrintf(format, a...)
}
deletePrintf = color.New(color.FgRed).PrintfFunc()
// DeletePrintf is fmt.Printf with green as foreground color.
DeletePrintf = func(format string, a ...interface{}) {
mu.Lock()
defer mu.Unlock()
deletePrintf(format, a...)
}
updatePrintf = color.New(color.FgYellow).PrintfFunc()
// UpdatePrintf is fmt.Printf with yellow as foreground color.
UpdatePrintf = func(format string, a ...interface{}) {
mu.Lock()
defer mu.Unlock()
updatePrintf(format, a...)
}
createPrintln = color.New(color.FgGreen).PrintlnFunc()
// CreatePrintln is fmt.Println with red as foreground color.
CreatePrintln = func(a ...interface{}) {
mu.Lock()
defer mu.Unlock()
createPrintln(a...)
}
deletePrintln = color.New(color.FgRed).PrintlnFunc()
// DeletePrintln is fmt.Println with green as foreground color.
DeletePrintln = func(a ...interface{}) {
mu.Lock()
defer mu.Unlock()
deletePrintln(a...)
}
updatePrintln = color.New(color.FgYellow).PrintlnFunc()
// UpdatePrintln is fmt.Println with yellow as foreground color.
UpdatePrintln = func(a ...interface{}) {
mu.Lock()
defer mu.Unlock()
updatePrintln(a...)
}
)