package config import ( "gopkg.in/yaml.v2" "os" ) var root Config type Config struct { Database Database `yaml:"database"` Users Users `yaml:"users"` Server Server `yaml:"server"` } func Get() Config { return root } func Load(path string) (Config, error) { f, err := os.Open(path) if err != nil { return Config{}, err } err = yaml.NewDecoder(f).Decode(&root) return root, err }