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 }