fix(util): return default config if os.UserHomeDir() returns err
This commit is contained in:
parent
d7c0fbb303
commit
56b4f74dff
1 changed files with 5 additions and 5 deletions
|
|
@ -17,15 +17,15 @@ type Config struct {
|
|||
|
||||
// NewConfig reads the configuration file (if exists) and returns a new config.
|
||||
func NewConfig() *Config {
|
||||
userHomeDir, err := os.UserHomeDir()
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
|
||||
c := Config{
|
||||
Mouse: true,
|
||||
GetMessagesLimit: 50,
|
||||
}
|
||||
|
||||
userHomeDir, err := os.UserHomeDir()
|
||||
if err != nil {
|
||||
return &c
|
||||
}
|
||||
configPath := userHomeDir + "/.config/discordo/config.json"
|
||||
if _, err := os.Stat(configPath); os.IsNotExist(err) {
|
||||
return &c
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue