package conf import ( "log" "os" "github.com/BurntSushi/toml" ) type ( Conf struct { Db Db Server Server } Db struct { Adapter string `toml:"DB_ADAPTER"` User string `toml:"DB_USER"` Password string `toml:"DB_PASS"` } Server struct { Hostname string `toml:"SERVER_HOSTNAME"` Port string `toml:"SERVER_PORT"` } ) func Load() *Conf { filepath := os.Getenv("NEWSSTAND_CONFIG_PATH") if filepath == "" { workingdir, err := os.Getwd() if err != nil { log.Fatal(err) } filepath = workingdir + "/.newsstandrc.toml" } log.Printf("Config file path: %s", filepath) var c Conf _, err := toml.DecodeFile(filepath, &c) if err != nil { log.Fatalln(err) } log.Println(c.Db.Adapter) return &c }