fix: create file when data store file not found

This commit is contained in:
trafficlunar 2025-03-22 14:41:54 +00:00
parent 8407a1258f
commit a1f22391e9

View file

@ -24,7 +24,9 @@ func InitDataStore() *DataStore {
file, err := os.Open("./data.json")
if err != nil {
if os.IsNotExist(err) {
slog.Warn("Data store file not found; creating new store")
slog.Warn("Data store file not found; creating new file")
GlobalDataStore.Save()
return GlobalDataStore
}
slog.Error("Could not load data store file!", slog.Any("error", err))
@ -38,7 +40,7 @@ func InitDataStore() *DataStore {
return nil
}
slog.Info("Loaded data store")
slog.Info("Data store loaded")
return GlobalDataStore
}