summaryrefslogtreecommitdiff
path: root/golang/pkg/database/tokens.go
diff options
context:
space:
mode:
authorJulien Dessaux2024-05-28 13:13:13 +0200
committerJulien Dessaux2024-05-28 13:13:13 +0200
commit0d00bf9fd242d3b4f9f3d6caaf5a61f8a3627d7f (patch)
tree3abe6c21ff22cd725fe1edd7e5d2e2d1478b4313 /golang/pkg/database/tokens.go
parent[node] send probes to visit all markets (diff)
downloadspacetraders-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.go11
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
}