mirror of
https://github.com/onsonr/sonr.git
synced 2025-03-10 13:07:09 +00:00
29 lines
480 B
Go
29 lines
480 B
Go
package proxy
|
|
|
|
import "github.com/spf13/viper"
|
|
|
|
type Config struct {
|
|
Host string `mapstructure:"HOST"`
|
|
Port string `mapstructure:"PORT"`
|
|
}
|
|
|
|
func (c *Config) GetHostname() string {
|
|
return c.Host + ":" + c.Port
|
|
}
|
|
|
|
func LoadConfig(path string) (config Config, err error) {
|
|
viper.AddConfigPath(path)
|
|
viper.SetConfigName("app")
|
|
viper.SetConfigType("env")
|
|
|
|
viper.AutomaticEnv()
|
|
|
|
err = viper.ReadInConfig()
|
|
if err != nil {
|
|
return
|
|
}
|
|
|
|
err = viper.Unmarshal(&config)
|
|
return
|
|
}
|