mirror of
https://github.com/mainnika/a-quest.git
synced 2026-05-24 00:33:36 +00:00
task3 backend
This commit is contained in:
@@ -0,0 +1,38 @@
|
||||
package configure
|
||||
|
||||
import (
|
||||
"strings"
|
||||
|
||||
"github.com/sirupsen/logrus"
|
||||
"github.com/spf13/viper"
|
||||
|
||||
"github.com/mainnika/a-quest/task3-backend/lib"
|
||||
"github.com/mainnika/a-quest/task3-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)
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user