a quest
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 

38 lines
651 B

package configure
import (
"strings"
"github.com/sirupsen/logrus"
"github.com/spf13/viper"
"github.com/mainnika/a-quest/task1-backend/lib"
"github.com/mainnika/a-quest/task1-backend/lib/env"
)
var Config lib.AppConfig
func init() {
path := env.ConfigPath
name := env.ConfigName
if len(path) == 0 {
path = lib.ConfPath
}
if len(name) == 0 {
name = lib.ConfName
}
viper.AddConfigPath(path)
viper.SetConfigName(name)
viper.SetEnvPrefix(env.Prefix)
viper.SetEnvKeyReplacer(strings.NewReplacer(".", "_"))
viper.AutomaticEnv()
err, _ := viper.ReadInConfig(), viper.Unmarshal(&Config)
if err != nil {
logrus.Fatal(err)
}
}