-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathexample_test.go
More file actions
45 lines (39 loc) · 992 Bytes
/
Copy pathexample_test.go
File metadata and controls
45 lines (39 loc) · 992 Bytes
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
package stringutil_test
import (
"fmt"
"github.com/azghr/forge/stringutil"
)
func ExampleTitle() {
fmt.Println(stringutil.Title("hello world"))
fmt.Println(stringutil.Title("go is awesome"))
fmt.Println(stringutil.Title("123 test"))
// Output:
// Hello World
// Go Is Awesome
// 123 Test
}
func ExampleSlug() {
fmt.Println(stringutil.Slug("Hello World"))
fmt.Println(stringutil.Slug("Go Lang Library"))
fmt.Println(stringutil.Slug("Hello, Go!"))
// Output:
// hello-world
// go-lang-library
// hello-go
}
func ExampleSlug_options() {
fmt.Println(stringutil.Slug("Hello World", stringutil.WithSeparator("_")))
fmt.Println(stringutil.Slug("Hello World Foo", stringutil.WithMaxLength(11)))
// Output:
// hello_world
// hello-world
}
func ExampleRemoveAccents() {
fmt.Println(stringutil.RemoveAccents("café"))
fmt.Println(stringutil.RemoveAccents("naïve"))
fmt.Println(stringutil.RemoveAccents("crème brûlée"))
// Output:
// cafe
// naive
// creme brulee
}