-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathyamlUse.go
46 lines (39 loc) · 863 Bytes
/
yamlUse.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"
"io/ioutil"
"log"
"os"
"github.com/sirupsen/logrus"
yaml "gopkg.in/yaml.v2"
)
func main() {
file, err := os.Open("./kodo-dev.yml")
if err != nil {
logrus.Fatal(err)
}
data, err := ioutil.ReadAll(file)
if err != nil {
logrus.Fatal(err)
}
fmt.Printf("string(data) = %+v\n", string(data))
result := map[string]interface{}{}
err = yaml.Unmarshal(data, &result)
if err != nil {
log.Fatal(err)
}
fmt.Println(err)
fmt.Println(result["storage"])
storage := result["storage"].(map[interface{}]interface{})
mymap := map[string]interface{}{}
for k, v := range storage {
mymap[k.(string)] = v
}
fmt.Println(mymap["kodo"])
kodo := mymap["kodo"].(map[interface{}]interface{})
kodoMap := map[string]interface{}{}
for k, v := range kodo {
kodoMap[k.(string)] = v
}
fmt.Println(kodoMap["rootdirectory"])
}