handle unknown home gracefully
parent
7d4b9549fa
commit
6da9e7a17d
|
@ -10,7 +10,6 @@ import (
|
|||
"git.kle.li/tools/go-import-redirector/pkg/configuration/file"
|
||||
"git.kle.li/tools/go-import-redirector/pkg/packagelist"
|
||||
"github.com/fsnotify/fsnotify"
|
||||
"github.com/spf13/cobra"
|
||||
"github.com/spf13/viper"
|
||||
)
|
||||
|
||||
|
@ -33,9 +32,12 @@ func New(cfgFile string, hotReload bool, reloadFunction func()) *Configuration {
|
|||
} else {
|
||||
// Find home directory.
|
||||
home, err := os.UserHomeDir()
|
||||
cobra.CheckErr(err)
|
||||
if err == nil {
|
||||
c.v.AddConfigPath(home)
|
||||
} else {
|
||||
fmt.Println("Unable to determine $HOME, not searching it for potential config")
|
||||
}
|
||||
|
||||
c.v.AddConfigPath(home)
|
||||
c.v.AddConfigPath("/etc/")
|
||||
c.v.AddConfigPath(".")
|
||||
c.v.SetConfigType("yaml")
|
||||
|
|
Loading…
Reference in New Issue