package utils import ( "fmt" "github.com/spf13/viper" "strings" ) var configFile = "config.yaml" var configExampleFile = "config.example.yaml" func ReadConf() { viper.SetConfigFile(configFile) if !IsFileExist(configFile) { fmt.Println(fmt.Sprintf("[service] config.yaml not found, creating one from template: %s", configExampleFile)) if err := CopyFile(configExampleFile, configFile); err != nil { fmt.Println(err) } } if err := viper.ReadInConfig(); err != nil { panic(err) } viper.AutomaticEnv() viper.SetEnvKeyReplacer(strings.NewReplacer(".", "_")) }