gopkg.in/frapposelli/wwhrd.v0@v0.2.1/config.go (about) 1 package main 2 3 import ( 4 "os" 5 6 yaml "github.com/cloudfoundry-incubator/candiedyaml" 7 ) 8 9 type Config struct { 10 Whitelist []string `yaml:"whitelist"` 11 Blacklist []string `yaml:"blacklist"` 12 Exceptions []string `yaml:"exceptions"` 13 } 14 15 func ReadConfig(path string) (*Config, error) { 16 17 if _, err := os.Stat(path); os.IsNotExist(err) { 18 return nil, err 19 } 20 21 f, err := os.Open(path) 22 if err != nil { 23 return nil, err 24 } 25 defer f.Close() 26 27 t := Config{} 28 if err = yaml.NewDecoder(f).Decode(&t); err != nil { 29 return nil, err 30 } 31 32 return &t, nil 33 }