From c04932383e4e5ff2093cf01b51ffb4bfbe00eb6a Mon Sep 17 00:00:00 2001 From: Jason Streifling Date: Sun, 8 Oct 2023 15:13:22 +0200 Subject: [PATCH] Reihenfolge der ausgegebenen Ergebnisse umgedreht --- packages/db/db.go | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/packages/db/db.go b/packages/db/db.go index 05389bb..5596aa4 100644 --- a/packages/db/db.go +++ b/packages/db/db.go @@ -37,6 +37,12 @@ func getCredentials() (string, string, error) { return strings.TrimSpace(user), strings.TrimSpace(pass), nil } +func reverseOrder(bs *[]types.Briefing) { + for i, j := 0, len(*bs)-1; i < j; i, j = i+1, j-1 { + (*bs)[i], (*bs)[j] = (*bs)[j], (*bs)[i] + } +} + func Open(dbName string) (*DB, error) { var err error db := new(DB) @@ -108,6 +114,7 @@ func (db *DB) ReadAll() (*[]types.Briefing, error) { bs = append(bs, *b) } + reverseOrder(&bs) return &bs, nil } @@ -145,5 +152,6 @@ func (db *DB) ReadByName(name string) (*[]types.Briefing, error) { bs = append(bs, *b) } + reverseOrder(&bs) return &bs, nil }