package config import ( "os" fp "path/filepath" "github.com/BurntSushi/toml" ) var ConfigPath string func init() { conf, _ := os.UserConfigDir() ConfigPath = fp.Join(conf, "my-log", "config.toml") } func Load() (Config, error) { c, _ := DefaultConfig() _, err := os.Stat(ConfigPath) if os.IsNotExist(err) { return c, nil } _, err = toml.DecodeFile(ConfigPath, &c) // @todo get environ return c, err }