package config import ( "github.com/spf13/viper" "log" ) type servUrls struct { EsUrl string `mapstructure: "esUrl"` ServerUrl string `mapstructure: "serverUrl"` } var ServUrls = &servUrls{} func Init(env string) { var err error viper.SetConfigType("yaml") viper.SetConfigName(env) viper.AddConfigPath("config") err = viper.ReadInConfig() if err != nil { log.Fatal("error on parsing configuration file", err) } viper.UnmarshalKey("servUrls", ServUrls) }