Last active
August 29, 2015 14:13
-
-
Save vrecan/47d87efeb753e398aeb0 to your computer and use it in GitHub Desktop.
go code to handle yaml with struct
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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