commit 03dd05207c2669684feac1db267368b11c6acee6
parent 3631c6e47818399e9b6fc2759b09bde2bdcfc12a
Author: Vetle Haflan <vetle@haflan.dev>
Date: Tue, 14 Apr 2020 22:31:14 +0200
Empty slices instead of nil -> no longer breaks client
Diffstat:
2 files changed, 6 insertions(+), 4 deletions(-)
diff --git a/internal/events/events.go b/internal/events/events.go
@@ -31,7 +31,8 @@ type Event struct {
}
// GetAll returns all events in the database
-func GetAll() (events []*Event) {
+func GetAll() ([]*Event) {
+ events := []*Event{}
db := database.GetDB()
err := db.View(func(tx *bbolt.Tx) error {
b := tx.Bucket(database.BucketKeyEvents)
@@ -52,7 +53,7 @@ func GetAll() (events []*Event) {
if err != nil {
fmt.Println(err)
}
- return
+ return events
}
// Delete event with the given ID.
diff --git a/internal/services/services.go b/internal/services/services.go
@@ -45,7 +45,8 @@ func GetByID(id uint64) *Service {
}
// GetAll returns all services in the database (TODO)
-func GetAll() (services []*Service) {
+func GetAll() ([]*Service) {
+ services := []*Service{}
db := database.GetDB()
db.View(func(tx *bbolt.Tx) error {
b := tx.Bucket(database.BucketKeyServices)
@@ -69,7 +70,7 @@ func GetAll() (services []*Service) {
return nil
})
})
- return
+ return services
}
// Delete deletes the given service if it exists