diff options
| author | Mitch Riedstra <mitch@riedstra.us> | 2016-12-30 22:32:01 -0500 |
|---|---|---|
| committer | Mitch Riedstra <mitch@riedstra.us> | 2016-12-30 22:32:01 -0500 |
| commit | 6acceb7b7404f2f71541d8a1cccc4758d1f80735 (patch) | |
| tree | 82eff717ddcd2baeca493fa0b2215e8dd752b612 /config | |
| download | steam-export-6acceb7b7404f2f71541d8a1cccc4758d1f80735.tar.gz steam-export-6acceb7b7404f2f71541d8a1cccc4758d1f80735.tar.xz | |
Initial
Diffstat (limited to 'config')
| -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) +} |
