package config import ( "io/ioutil" "gopkg.in/yaml.v3" ) type Database struct { Host string `yaml:"host"` Port int `yaml:"port"` Name string `yaml:"name"` User string `yaml:"user"` Password string `yaml:"password"` } type Publisher struct { Name string `yaml:"name"` Topics []string `yaml:"topics"` } type Config struct { Database Database `yaml:"db"` Publishers map[string]Publisher `yaml:"publishers"` } var DefaultConfigFile = "/etc/sensenet/sensenet.yaml" func LoadConfig(path string) (*Config, error) { data, err := ioutil.ReadFile(path) if err != nil { return nil, err } config := &Config{} err = yaml.Unmarshal(data, config) if err != nil { return nil, err } return config, nil }