mirror of
https://github.com/mentos1386/zdravko.git
synced 2024-11-21 23:33:34 +00:00
27 lines
476 B
Go
27 lines
476 B
Go
package config
|
|
|
|
import (
|
|
"os"
|
|
|
|
"github.com/spf13/viper"
|
|
)
|
|
|
|
func GetEnvOrDefault(key, def string) string {
|
|
value := os.Getenv(key)
|
|
if value == "" {
|
|
return def
|
|
}
|
|
return value
|
|
}
|
|
|
|
func newViper() *viper.Viper {
|
|
v := viper.New()
|
|
v.SetConfigName("zdravko")
|
|
v.SetConfigType("yaml")
|
|
v.AddConfigPath("/etc/zdravko/")
|
|
v.AddConfigPath("$HOME/.zdravko")
|
|
v.AddConfigPath("$HOME/.config/zdravko")
|
|
v.AddConfigPath("$XDG_CONFIG_HOME/zdravko")
|
|
v.AddConfigPath(".")
|
|
return v
|
|
}
|