From 6acceb7b7404f2f71541d8a1cccc4758d1f80735 Mon Sep 17 00:00:00 2001 From: Mitch Riedstra Date: Fri, 30 Dec 2016 22:32:01 -0500 Subject: Initial --- config/config.go | 35 +++++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) create mode 100644 config/config.go (limited to 'config/config.go') diff --git a/config/config.go b/config/config.go new file mode 100644 index 0000000..541505e --- /dev/null +++ b/config/config.go @@ -0,0 +1,35 @@ +package config + +import ( + "gopkg.in/yaml.v2" + "io/ioutil" +) + +var ( + defaultConfig string = "config.yml" +) + +type Config struct { + // Repos []string + // map[string]map[string]interface{} + SteamRepositories []string `yaml:"SteamRepositories"` + Listen string +} + +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) +} -- cgit v1.2.3