package main import ( "log" "os" "path/filepath" "github.com/spf13/viper" ) func readConfig() { // configFile executable, err := os.Executable() if err != nil { log.Fatal("err") } executableDir := filepath.Dir(executable) viper.SetConfigType("yaml") viper.SetConfigName("goipam") viper.AddConfigPath(executableDir) viper.AddConfigPath("/etc") viper.SetDefault("web.host", "0.0.0.0") viper.SetDefault("web.port", 8080) viper.SetDefault("web.prod", true) err = viper.ReadInConfig() if err != nil { log.Fatal("err") } }