refactor: initialize default config when file is empty
This commit is contained in:
parent
61cf6f7383
commit
d815c77c29
2 changed files with 3 additions and 3 deletions
|
|
@ -78,12 +78,13 @@ func (c *Config) Load() {
|
|||
e := json.NewEncoder(f)
|
||||
e.SetIndent("", "\t")
|
||||
|
||||
c = New()
|
||||
err = e.Encode(c)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
} else {
|
||||
err = json.NewDecoder(f).Decode(&c)
|
||||
err = json.NewDecoder(f).Decode(c)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -22,7 +22,7 @@ type App struct {
|
|||
Session *discordgo.Session
|
||||
SelectedChannel *discordgo.Channel
|
||||
SelectedMessage int
|
||||
Config *config.Config
|
||||
Config config.Config
|
||||
}
|
||||
|
||||
func NewApp() *App {
|
||||
|
|
@ -37,7 +37,6 @@ func NewApp() *App {
|
|||
|
||||
Session: s,
|
||||
SelectedMessage: -1,
|
||||
Config: config.New(),
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue