fix get users
alex wennerberg alex@alexwennerberg.com
Sat, 24 Oct 2020 13:13:41 -0700
1 files changed,
14 insertions(+),
1 deletions(-)
jump to
M
main.go
→
main.go
@@ -24,7 +24,20 @@ UpdatedTime time.Time
} func getUsers() ([]string, error) { - return []string{"me", "other guy"}, nil + rows, err := DB.Query(`SELECT username from user`) + if err != nil { + return nil, err + } + var users []string + for rows.Next() { + var user string + err = rows.Scan(&user) + if err != nil { + return nil, err + } + users = append(users, user) + } + return users, nil } /// Perform some checks to make sure the file is OK