summaryrefslogtreecommitdiff
path: root/golang/pkg/database/tokens.go
diff options
context:
space:
mode:
authorJulien Dessaux2024-05-06 00:18:22 +0200
committerJulien Dessaux2024-05-06 00:18:22 +0200
commit427cc77fa3633aca7c4c3377fa26b0e70921a7b5 (patch)
treecc8de99037ab539a0786f568cf217b680ac99ec3 /golang/pkg/database/tokens.go
parent[node] fix shortest path to only hop through refueling points (diff)
downloadspacetraders-427cc77fa3633aca7c4c3377fa26b0e70921a7b5.tar.gz
spacetraders-427cc77fa3633aca7c4c3377fa26b0e70921a7b5.tar.bz2
spacetraders-427cc77fa3633aca7c4c3377fa26b0e70921a7b5.zip
[golang] bootstrapped a client in yet another language
Diffstat (limited to '')
-rw-r--r--golang/pkg/database/tokens.go14
1 files changed, 14 insertions, 0 deletions
diff --git a/golang/pkg/database/tokens.go b/golang/pkg/database/tokens.go
new file mode 100644
index 0000000..16bda2b
--- /dev/null
+++ b/golang/pkg/database/tokens.go
@@ -0,0 +1,14 @@
+package database
+
+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
+}