Go YAML

Jmnote (토론 | 기여)님의 2021년 9월 24일 (금) 19:22 판 (→‎개요)

1 개요

Go YAML
package main
import (
        "fmt"
        "log"
        "gopkg.in/yaml.v2"
)
var data = `
a: Easy!
b:
  c: 2
  d: [3, 4]
`
type T struct {
        A string
        B struct {
                RenamedC int   `yaml:"c"`
                D        []int `yaml:",flow"`
        }
}
func main() {
        t := T{}
        err := yaml.Unmarshal([]byte(data), &t)
        if err != nil {
                log.Fatalf("error: %v", err)
        }
        fmt.Printf("--- t:\n%v\n\n", t)
}

2 같이 보기

3 참고

문서 댓글 ({{ doc_comments.length }})
{{ comment.name }} {{ comment.created | snstime }}