package config import ( "fmt" "github.com/BurntSushi/toml" ) type Config struct { CurrentAPI string `toml:"CurrentAPI"` APIToken string `toml:"APIToken"` QuestionsPath string `toml:"QuestionsPath"` OutPath string `toml:"OutPath"` } func LoadConfigOrDefault(fn string) *Config { if fn == "" { fn = "config.toml" } config := &Config{} _, err := toml.DecodeFile(fn, &config) if err != nil { fmt.Println("failed to read config from file, loading default", "error", err) config.CurrentAPI = "http://localhost:8080/completion" config.QuestionsPath = "data/questions.json" config.OutPath = "data/out.json" } return config }