-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathexample_test.go
59 lines (51 loc) · 1.75 KB
/
example_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
package tint_test
import (
"fmt"
"github.com/printzero/tint"
)
func Example() {
// Initialize tint
t := tint.Init()
// prints output in red
t.Println("This output is red", tint.Red)
}
// This example demonstrates how attributes are defined in colors and when and how to use those attributes.
// As of `v0.0.2`tint has 5 attributes: Dim, Bold, Italic, Underline, Strike (strikethrough)
// These attributes are functions that are exposed over the color struct.
func Example_attributes() {
// create pointer to Tint
t := tint.Init()
// Dim attribute
t.Println("Dim sentence.", tint.Yellow.Dim())
// Bold attribute
t.Println("Bold sentence.", tint.Yellow.Bold())
// Italic attribute
t.Println("Italic sentence.", tint.Yellow.Italic())
// Underline attribute
t.Println("Underlined sentence.", tint.Yellow.Underline())
// Strike attribute
t.Println("Strikeout sentence.", tint.Yellow.Strike())
}
// This example demonstrates how colors are accessed differently than tint functions.
func Example_difference() {
// create pointer to Tint
t := tint.Init()
// Notice: how Raw function is accessed through pointer created by Init()
// Notice: how color Yellow are accessed, they are static variables defined inside tint module
// so you don't have to create any instance of a color
t.Println("This output is red", tint.Yellow)
}
func ExampleTint_Raw() {
// Initialize tint
t := tint.Init()
// get a colored string to be used as terminal output
output := t.Raw("Rejoice fellow gopher, your test cases have passed.", tint.Green)
// use it anywhere as input - fmt, log ...
fmt.Println(output)
}
func ExampleTint_Exp() {
// Initialize tint
t := tint.Init()
coloredString := t.Exp("@(Hello), @(World)!", tint.White.Bold(), tint.Blue)
fmt.Println(coloredString)
}