-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.go
46 lines (35 loc) · 884 Bytes
/
main.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
package main
import (
"fmt"
tryablemap "github.com/HaraKeisuke/go-tryablemap/lib"
)
func main() {
data := map[string]interface{}{
"first": map[string]int{
"second": 123,
},
}
_map := tryablemap.New(data)
result := _map.Try("first").Value("second")
fmt.Println(result)
data2 := map[string][]string{
"sample": []string{
"first", "second", "third",
},
}
_map2 := tryablemap.New(data2)
result2 := _map2.TryArray("sample").Value(0)
fmt.Println(result2)
data3 := [][]int{
[]int{1, 2, 3}, []int{4, 5, 6}, []int{7, 8, 9},
}
_map3 := tryablemap.NewArray(data3)
result3 := _map3.TryArray(0).Value(2)
fmt.Println(result3)
data4 := map[string]interface{}{
"hoge": []map[string]interface{}{{"first": 1}, {"second": 2}, {"third": 3}},
}
_map4 := tryablemap.New(data4)
result4 := _map4.TryArray("hoge").Try(0).Value("first")
fmt.Println(result4)
}