-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathexample_test.go
62 lines (60 loc) · 1.14 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 prefixtree
import (
"fmt"
)
func ExampleNew() {
root := New()
fmt.Println(
root.SetString("/path/:dir/123", "value1"),
)
fmt.Println(
root.SetString("/path/:dir/*filepath", "value2"),
)
fmt.Println(
root.SetString("/path/user_:user", "value3"),
)
fmt.Println(
root.SetString("/id/:id", "value4"),
)
fmt.Println(
root.SetString("/id:id", "value5"),
)
fmt.Println(
root.SetString(":id/:name/123", "value6"),
)
fmt.Println(
root.SetString("/id:id", "value7"),
)
fmt.Println(
root.SetString("/id:id2", "value8"),
)
value, err := root.GetString("/path/123/file.zip")
fmt.Println(err)
fmt.Println(string(value.Path))
fmt.Println(value.String())
fmt.Println(value.Value)
items := View(root)
for _, item := range items {
fmt.Println(item)
}
// Output:
// <nil>
// <nil>
// <nil>
// <nil>
// <nil>
// <nil>
// path already in use
// <nil>
// <nil>
// /path/123/file.zip
// *filepath
// value2
// ^[/][path/]:dir[/][123]=value1
// ^[/][path/]:dir[/]*filepath=value2
// ^[/][path/][user_]:user=value3
// ^[/][id][/]:id=value4
// ^[/][id]:id=value5
// ^[/][id]:id2=value8
// ^:id[/]:name[/123]=value6
}