0.1.0 - First pass at the app

This commit is contained in:
2026-04-28 15:26:55 -06:00
parent 73aff92505
commit 7420e2b890
17 changed files with 254 additions and 25 deletions
+10 -2
View File
@@ -3,16 +3,24 @@ package lib
import (
"database/sql"
"log"
"os"
"path/filepath"
_ "turso.tech/database/tursogo"
)
var DB *sql.DB
// init sqlite db — always creates app.db at project root (run from root)
// init sqlite db — creates app.db at project root (run from root) or ROOT_DIR if set
func InitDB() {
var err error
DB, err = sql.Open("turso", "app.db")
dbPath := "app.db"
if rootDir := os.Getenv("ROOT_DIR"); rootDir != "" {
dbPath = filepath.Join(rootDir, "app.db")
}
DB, err = sql.Open("turso", dbPath)
if err != nil {
log.Fatal(err)
}