25 lines
526 B
Go
25 lines
526 B
Go
package config
|
|
|
|
import (
|
|
"fmt"
|
|
|
|
"github.com/spf13/viper"
|
|
)
|
|
|
|
func init() {
|
|
viper.SetConfigName("musicutil")
|
|
viper.SetConfigType("yaml")
|
|
viper.AddConfigPath("$HOME/.config")
|
|
viper.AddConfigPath("$XDG_CONFIG_HOME")
|
|
|
|
viper.SetDefault("log_level", "info")
|
|
viper.SetDefault("cache", false)
|
|
viper.SetDefault("cache_dir", "source_dir")
|
|
|
|
if err := viper.ReadInConfig(); err != nil {
|
|
if _, isNotFound := err.(viper.ConfigFileNotFoundError); !isNotFound {
|
|
panic(fmt.Errorf("Fatal error config file: %w \n", err))
|
|
}
|
|
}
|
|
}
|