diff options
author | Julien Dessaux | 2024-05-28 13:13:13 +0200 |
---|---|---|
committer | Julien Dessaux | 2024-05-28 13:13:13 +0200 |
commit | 0d00bf9fd242d3b4f9f3d6caaf5a61f8a3627d7f (patch) | |
tree | 3abe6c21ff22cd725fe1edd7e5d2e2d1478b4313 /golang/pkg/database/tokens.go | |
parent | [node] send probes to visit all markets (diff) | |
download | spacetraders-0d00bf9fd242d3b4f9f3d6caaf5a61f8a3627d7f.tar.gz spacetraders-0d00bf9fd242d3b4f9f3d6caaf5a61f8a3627d7f.tar.bz2 spacetraders-0d00bf9fd242d3b4f9f3d6caaf5a61f8a3627d7f.zip |
[golang] fixed golang api client design mistakes
Diffstat (limited to 'golang/pkg/database/tokens.go')
-rw-r--r-- | golang/pkg/database/tokens.go | 11 |
1 files changed, 4 insertions, 7 deletions
diff --git a/golang/pkg/database/tokens.go b/golang/pkg/database/tokens.go index 16bda2b..0787b5c 100644 --- a/golang/pkg/database/tokens.go +++ b/golang/pkg/database/tokens.go @@ -1,14 +1,11 @@ package database -func (db DB) AddToken(token string) error { +func (db *DB) AddToken(token string) error { _, err := db.db.ExecContext(db.ctx, `INSERT INTO tokens(data) VALUES (?);`, token) return err } -func (db DB) GetToken() (string, error) { - var token string - if err := db.db.QueryRowContext(db.ctx, `SELECT data FROM tokens;`).Scan(&token); err != nil { - return "", err - } - return token, nil +func (db *DB) GetToken() (token string, err error) { + err = db.db.QueryRowContext(db.ctx, `SELECT data FROM tokens;`).Scan(&token) + return token, err } |