-
Notifications
You must be signed in to change notification settings - Fork 0
/
example_test.go
62 lines (47 loc) · 1.17 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
60
61
62
package text_test
import (
"fmt"
"github.com/x-ethr/text"
)
func ExampleLowercase() {
v := "Field-Name"
fmt.Println(text.Lowercase(v))
// Output: field-name
}
func ExampleTitle() {
// v represents a name that should be otherwise capitalized (titled)
v := "jacob b. sanders"
fmt.Println(text.Title(v))
// Output: Jacob B. Sanders
}
func ExampleVariadic() {
v := text.Dereference(nil, func(o *text.Options) {
o.Log = true
})
fmt.Println(v)
// Output:
pointer := text.Pointer("example")
v = text.Dereference(pointer, func(o *text.Options) {
o.Log = true
})
fmt.Println(v)
// Output: example
}
func ExampleDereference() {
// initialize a string pointer of underlying value "example"
pointer := text.Pointer("example")
// establish variable "v" of type string
v := text.Dereference(pointer, func(o *text.Options) {
o.Log = true // log if the pointer is nil
})
fmt.Println(v)
// Output: example
}
func ExamplePointer() {
// create a pointer of type string with reference value: "example"
pointer := text.Pointer("example", func(o *text.Options) {
o.Log = true // log if the string value is an empty string
})
fmt.Println(*(pointer))
// Output: example
}