diff options
Diffstat (limited to 'config/config.go')
| -rw-r--r-- | config/config.go | 35 |
1 files changed, 35 insertions, 0 deletions
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) +} |
