goipam/config.go

33 lines
546 B
Go
Raw Normal View History

2024-02-22 10:18:59 +01:00
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")
}
}