package config
import (
"..."
"github.com/spf13/viper"
)
// Read attempts to read a config file from path.
// The defaults provided will be used if no config file doesn't exist
func Read(name string, defaults map[string]interface{}) *viper.Viper {
v := viper.New()
v.SetConfigFile(name)
v.AddConfigPath(".")
v.AutomaticEnv()
for key, val := range defaults {
v.SetDefault(key, val)
}
err := v.ReadInConfig()
if err != nil {
log.Info("Internal", "config", "proceeding with defaults and env vars")
}
return v
}
example config package