package main import ( // External "gopkg.in/yaml.v3" // Standard "errors" "io/ioutil" ) type Config struct { Websocket struct { Domains []string } Database struct { Host string Port int Name string Username string Password string } Application struct { StaticDir string } Session struct { DaysValid int } } func ConfigRead(filename string) (config Config, err error) { var rawConfigData []byte rawConfigData, err = ioutil.ReadFile(filename) if err != nil { return } err = yaml.Unmarshal(rawConfigData, &config) if err != nil { return } if config.Session.DaysValid == 0 { err = errors.New("Configuration: session.daysvalid needs to be higher than 0.") } return }