-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtest.go
101 lines (80 loc) · 2.33 KB
/
test.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
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
package main
import (
"errors"
"fmt"
"github.com/gookit/color"
"github.com/qsirwyk/golib/util"
"log"
"time"
)
func init() {
//log.SetFlags(log.Lshortfile | log.Ldate | log.Ltime)
//log.SetPrefix("[GoLib] ")
}
func main() {
testColor()
//testTrace()
//util.BlockMain()
//testErr()
//testClear()
}
func testRc4() {
}
func rc4() {
}
func testClear() {
fmt.Println("I will clean the screen in 2 seconds!")
time.Sleep(2 * time.Second)
util.ClearScreen()
fmt.Println("I'm alone...")
}
func testErr() {
util.CheckErrf(errors.New("test"), "%d|%d", 123, 456)
util.CheckExitErr(errors.New("err"))
util.CheckErrf(errors.New("test"), "%d|%d", 123, 456)
util.CheckErr(errors.New("err"))
}
func testTrace() {
util.Trace("util.trace", 1)
log.Printf("%s test2", "func")
}
func testColor() {
// quick use package func
color.Redp("Simple to use color")
color.Redln("Simple to use color")
color.Greenp("Simple to use color\n")
color.Cyanln("Simple to use color")
color.Yellowln("Simple to use color")
// quick use like fmt.Print*
color.Red.Println("Simple to use color")
color.Green.Print("Simple to use color\n")
color.Cyan.Printf("Simple to use %s\n", "color")
color.Yellow.Printf("Simple to use %s\n", "color")
// use like func
red := color.FgRed.Render
green := color.FgGreen.Render
fmt.Printf("%s line %s library\n", red("Command"), green("color"))
// custom color
color.New(color.FgWhite, color.BgBlack).Println("custom color style")
// can also:
color.Style{color.FgCyan, color.OpBold}.Println("custom color style")
// internal theme/style:
color.Info.Tips("message")
color.Info.Prompt("message")
color.Info.Println("message")
color.Warn.Println("message")
color.Error.Println("message")
// use style tag
color.Print("<suc>he</><comment>llo</>, <cyan>wel</><red>come</>\n")
// Custom label attr: Supports the use of 16 color names, 256 color values, rgb color values and hex color values
color.Println("<fg=11aa23>he</><bg=120,35,156>llo</>, <fg=167;bg=232>wel</><fg=red>come</>")
// apply a style tag
color.Tag("info").Println("info style text")
// prompt message
color.Info.Prompt("prompt style message")
color.Warn.Prompt("prompt style message")
// tips message
color.Info.Tips("tips style message")
color.Warn.Tips("tips style message")
color.Style{color.FgLightMagenta, color.OpBold}.Println("custom color style")
}