Fix go services returning nulls

I did not know that var foo []bar does not initialize foo to empty []!
Fuck
This commit is contained in:
2024-08-13 18:17:39 +02:00
parent 0e64ff9eb2
commit 0051ae71d9
2 changed files with 10 additions and 10 deletions

View File

@@ -24,7 +24,7 @@ const weightcolumns = "rowid, date, weight"
const weightAggregatedColumns = "period, amount"
func (w *WeightService) GetRecent() ([]Weight, error) {
var res []Weight
res := []Weight{}
if w.db == nil || !w.db.Ready {
return res, fmt.Errorf("cannot get recent weight, db is nil or is not ready")
}
@@ -88,7 +88,7 @@ func (w *WeightService) GetByRowid(rowid int64) (Weight, error) {
// I could probably refactor this to be less of a disaster...
// But I think it'll work for now
func (w *WeightService) GetDaily() ([]AggregatedWeight, error) {
var res []AggregatedWeight
res := []AggregatedWeight{}
if w.db == nil || !w.db.Ready {
return res, fmt.Errorf("cannot get daily weight, db is nil or is not ready")
}
@@ -114,7 +114,7 @@ func (w *WeightService) GetDaily() ([]AggregatedWeight, error) {
}
func (w *WeightService) GetWeekly() ([]AggregatedWeight, error) {
var res []AggregatedWeight
res := []AggregatedWeight{}
if w.db == nil || !w.db.Ready {
return res, fmt.Errorf("cannot get weekly weight, db is nil or is not ready")
}
@@ -140,7 +140,7 @@ func (w *WeightService) GetWeekly() ([]AggregatedWeight, error) {
}
func (w *WeightService) GetMonthly() ([]AggregatedWeight, error) {
var res []AggregatedWeight
res := []AggregatedWeight{}
if w.db == nil || !w.db.Ready {
return res, fmt.Errorf("cannot get monthly weight, db is nil or is not ready")
}
@@ -166,7 +166,7 @@ func (w *WeightService) GetMonthly() ([]AggregatedWeight, error) {
}
func (w *WeightService) GetYearly() ([]AggregatedWeight, error) {
var res []AggregatedWeight
res := []AggregatedWeight{}
if w.db == nil || !w.db.Ready {
return res, fmt.Errorf("cannot get yearly weight, db is nil or is not ready")
}