Skip to content

Instantly share code, notes, and snippets.

@locona
Created May 29, 2018 07:34
Show Gist options
  • Select an option

  • Save locona/610e89ab9039f70b541eacf01439aeb9 to your computer and use it in GitHub Desktop.

Select an option

Save locona/610e89ab9039f70b541eacf01439aeb9 to your computer and use it in GitHub Desktop.
package main
import (
"io/ioutil"
"github.com/k0kubun/pp"
yaml "gopkg.in/yaml.v2"
)
type Data struct {
Components []Component `yaml:"components"`
}
type Component struct {
Service string `yaml:"service"`
Fields []Field `yaml:"fields"`
}
type Field struct {
Key string
Label string
}
func main() {
buf, err := ioutil.ReadFile("sample.yaml")
if err != nil {
panic(err)
}
d := &Data{}
if err := yaml.Unmarshal(buf, d); err != nil {
panic(err)
}
pp.Println(d)
}
@locona
Copy link
Author

locona commented May 29, 2018

components:
  -
      service: adjust
      fields:
        - key api_key:
          label: API Key
        - key: sdk_key
          label: SDK Key

  -
      service: appapnnie
      fields:
        - key api_key:
          label: API Key
        - key: sdk_key
          label: SDK Key

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment