diff --git a/core/action.go b/core/action.go index 57bfa44..5a5775e 100644 --- a/core/action.go +++ b/core/action.go @@ -42,6 +42,7 @@ func GetActionsForSource(db DB, source string) ([]string, error) { if err != nil { return nil, err } + defer rows.Close() var names []string for rows.Next() { var name string @@ -51,6 +52,9 @@ func GetActionsForSource(db DB, source string) ([]string, error) { } names = append(names, name) } + if err := rows.Err(); err != nil { + return nil, err + } return names, nil } diff --git a/core/env.go b/core/env.go index 3330daa..7c5b94c 100644 --- a/core/env.go +++ b/core/env.go @@ -14,6 +14,7 @@ func GetEnvs(db DB, source string) ([]string, error) { if err != nil { return nil, err } + defer rows.Close() var envs []string for rows.Next() { var name string @@ -23,6 +24,9 @@ func GetEnvs(db DB, source string) ([]string, error) { } envs = append(envs, fmt.Sprintf("%s=%s", name, value)) } + if err := rows.Err(); err != nil { + return nil, err + } return envs, nil } diff --git a/core/items.go b/core/items.go index 5e695dd..de5b3a5 100644 --- a/core/items.go +++ b/core/items.go @@ -128,6 +128,7 @@ func getItems(db DB, query string, args ...any) ([]Item, error) { if err != nil { return nil, err } + defer rows.Close() var items []Item for rows.Next() { var item Item @@ -137,6 +138,9 @@ func getItems(db DB, query string, args ...any) ([]Item, error) { } items = append(items, item) } + if err := rows.Err(); err != nil { + return nil, err + } return items, nil } diff --git a/core/migrations.go b/core/migrations.go index c5a1d4a..f83938a 100644 --- a/core/migrations.go +++ b/core/migrations.go @@ -23,6 +23,7 @@ func InitDatabase(db DB) error { if err != nil { return err } + defer rows.Close() var exists bool for rows.Next() { @@ -31,6 +32,9 @@ func InitDatabase(db DB) error { return err } } + if err := rows.Err(); err != nil { + return err + } if exists { return nil @@ -56,6 +60,7 @@ func GetPendingMigrations(db DB) (map[string]bool, error) { if err != nil { return nil, err } + defer rows.Close() for rows.Next() { var name string err = rows.Scan(&name) @@ -64,6 +69,9 @@ func GetPendingMigrations(db DB) (map[string]bool, error) { } complete[name] = true } + if err := rows.Err(); err != nil { + return nil, err + } return complete, nil } diff --git a/core/source.go b/core/source.go index 689ddb3..3f186ce 100644 --- a/core/source.go +++ b/core/source.go @@ -25,6 +25,7 @@ func GetSources(db DB) ([]string, error) { if err != nil { return nil, err } + defer rows.Close() var names []string for rows.Next() { var name string @@ -33,6 +34,9 @@ func GetSources(db DB) ([]string, error) { } names = append(names, name) } + if err := rows.Err(); err != nil { + return nil, err + } return names, nil }