github.com/gogf/gf@v1.16.9/.example/encoding/gyaml/gyaml.go (about) 1 package main 2 3 import ( 4 "fmt" 5 6 "github.com/gogf/gf/encoding/gyaml" 7 ) 8 9 func main() { 10 var yamlStr string = ` 11 #即表示url属性值; 12 url: http://www.wolfcode.cn 13 #即表示server.host属性的值; 14 server: 15 host: http://www.wolfcode.cn 16 #数组,即表示server为[a,b,c] 17 server: 18 - 120.168.117.21 19 - 120.168.117.22 20 - 120.168.117.23 21 #常量 22 pi: 3.14 #定义一个数值3.14 23 hasChild: true #定义一个boolean值 24 name: '你好YAML' #定义一个字符串 25 ` 26 27 i, err := gyaml.Decode([]byte(yamlStr)) 28 fmt.Println(err) 29 fmt.Println(i) 30 }