You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
28 lines
536 B
Go
28 lines
536 B
Go
package config
|
|
|
|
import (
|
|
"github.com/spf13/viper"
|
|
)
|
|
|
|
type Config struct {
|
|
PostgresDriver string `mapstructure:"POSTGRES_DRIVER"`
|
|
PostgresSource string `mapstructure:"POSTGRES_SOURCE"`
|
|
PostgresPort string `mapstructure:"POSTGRES_PORT"`
|
|
}
|
|
|
|
func LoadConfig(path string) (config Config, err error) {
|
|
viper.AddConfigPath(path)
|
|
viper.SetConfigType("env")
|
|
viper.SetConfigName("app")
|
|
|
|
viper.AutomaticEnv()
|
|
|
|
err = viper.ReadInConfig()
|
|
if err != nil {
|
|
return
|
|
}
|
|
|
|
err = viper.Unmarshal(&config)
|
|
return
|
|
}
|