Skip to content

Instantly share code, notes, and snippets.

@vrecan
Last active August 29, 2015 14:13
Show Gist options
  • Save vrecan/47d87efeb753e398aeb0 to your computer and use it in GitHub Desktop.
Save vrecan/47d87efeb753e398aeb0 to your computer and use it in GitHub Desktop.
go code to handle yaml with struct
type Conf struct {
ReportSeconds int32 `yaml:"reportSeconds"`
Monitor []string `yaml:"monitor"`
}
func GetConf(path string) (c Conf, err error) {
data, err := ioutil.ReadFile(path)
if nil != err {
return c, err
}
err = yaml.Unmarshal([]byte(data), &c)
return c, err
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment