// Used to define and load this application's specific configuration package config import ( "gopkg.in/yaml.v2" "io/ioutil" ) var ( defaultConfig string = "config.yml" ) type Config struct { SteamRepositories []string `yaml:"SteamRepositories"` Listen string } // By default it reads 'config.yml' in the current directory func LoadConfig() (*Config, error) { c := &Config{} err := c.ReadDefaultConfig() return c, err } func (c *Config) ReadDefaultConfig() error { return c.ReadConfig(defaultConfig) } func (c *Config) ReadConfig(cfg string) error { contents, err := ioutil.ReadFile(cfg) if err != nil { return err } return yaml.Unmarshal([]byte(contents), c) }