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
490 B
Go
28 lines
490 B
Go
2 years ago
|
package config
|
||
|
|
||
|
import (
|
||
|
"github.com/spf13/viper"
|
||
|
)
|
||
|
|
||
|
type Config struct {
|
||
|
PostgreDriver string `mapstructure:"POSTGRES_DRIVER"`
|
||
|
PostgresSource string `mapstructure:"POSTGRES_SOURCE"`
|
||
|
|
||
|
Port string `mapstructure:"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
|
||
|
}
|