package main import ( "encoding/json" "fmt" "git.kirsle.net/go/yamlsettings" ) type MyProj struct { Databases struct { PrimarySQL struct { User string `yaml:"user"` Passwd string `yaml:"passwd"` Host string `yaml:"host"` DB string `yaml:"db"` Compress bool `yaml:"compress"` Engine string `yaml:"engine"` } `yaml:"primary_sql"` Redis struct { Host string `yaml:"redis_host"` Port int `yaml:"redis_port"` } `yaml:"redis"` } `yaml:"databases"` AppConfig struct { Debug bool `yaml:"DEBUG"` SecretKey string `yaml:"SECRET_KEY"` } `yaml:"app_config"` DebugSQL bool `yaml:"debug_sql"` DebugProfiler bool `yaml:"debug_profiler"` } func (c MyProj) String() string { output, _ := json.MarshalIndent(c, "", "\t") return string(output) } func main() { var config MyProj err := yamlsettings.LoadFiles( "defaults.yml", "settings.yml2", &config, ) if err != nil { panic(err) } // Print out the final settings to terminal as JSON. fmt.Println(config) }