-
Notifications
You must be signed in to change notification settings - Fork 3
/
example_color_style_test.go
67 lines (51 loc) · 1.8 KB
/
example_color_style_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
package colorstyle_test
import (
"fmt"
"github.com/flylog/colorstyle"
)
func Example() {
text := colorstyle.Green("green")
fmt.Printf("a %s text\n", text)
text = colorstyle.Blue("Blue")
fmt.Printf("a %s text\n", text)
text = colorstyle.New().ColorRed().Sprint("red")
fmt.Println("a", text, "text")
colorstyle.New().StyleItalic().ColorRed().BgYellow().Printf("a italic red bgYellow text: %s\n", "Hello 世界!")
colorstyle.New().StyleBold().Printf("a bold text: %s\n", "Hello 世界!")
colorstyle.New().StyleItalic().Printf("a italic text: %s\n", "Hello 世界!")
colorstyle.New().ColorMagenta().Printf("a magenta text: %s\n", "Hello 世界!")
colorstyle.New().BgCyan().Printf("a background color cyan text: %s\n", "Hello 世界!")
colorstyle.New().BgCyan().Println("a background color cyan text")
css := colorstyle.New()
css.StyleStrikethrough().Println("删除线文本")
css.StyleUnderline().Println("下划线文本")
css.StyleReverse().Println("反显文本")
}
func ExampleGreen() {
text := colorstyle.Green("green")
fmt.Printf("a %s text\n", text)
}
func ExampleBlue() {
text := colorstyle.Blue("Blue")
fmt.Printf("a %s text\n", text)
}
func ExampleNew() {
css := colorstyle.New()
css.StyleItalic().ColorGreen().BgYellow()
css.Printf("a italic green bgYellow text: %s\n", "Hello 世界!")
}
func ExampleCSS_StyleBold() {
colorstyle.New().StyleBold().Printf("a bold text: %s\n", "Hello 世界!")
// or
css := colorstyle.New().StyleBold()
css.Printf("a bold text: %s\n", "Hello 世界!")
}
func ExampleCSS_ColorRed() {
colorstyle.New().ColorRed().Printf("a bold text: %s\n", "Hello 世界!")
}
func ExampleCSS_Printf() {
colorstyle.New().ColorRed().Printf("a bold text: %s\n", "Hello 世界!")
}
func ExampleCSS_Println() {
colorstyle.New().BgBlue().Println("a background color blue text")
}