package main import ( "flag" "gopkg.in/yaml.v2" "io/ioutil" ) type Config struct { Gofname string `yaml:"gofname"` Goimpldir string `yaml:"goimpldir"` Tsfname string `json:"tsfname"` Goclifname string `json:"goclifname"` } var config Config func loadConfig() { fname := flag.String("f", ".apigen.yaml", "File with config to load - defaults to '.apigen'") flag.Parse() bs, err := ioutil.ReadFile(*fname) Err(err) err = yaml.Unmarshal(bs, &config) Err(err) }