package main import ( "fmt" "log" "net/http" _ "github.com/mattn/go-sqlite3" "shelves/db" "shelves/httpx" "shelves/routes" ) func main() { db, migrateResult, err := db.Open("./shelves.db") if err != nil { log.Fatalf("Failed to open DB: %v", err) } if migrateResult.MigrationError != nil { log.Printf("An error was encountered while upgrading the database schema. You are on version %v, but the latest is %v. The error was: %v", migrateResult.SchemaVerNew, migrateResult.SchemaVerLatest, migrateResult.MigrationError) } schemaNeedsUpdating := migrateResult.SchemaVerNew != migrateResult.SchemaVerLatest if schemaNeedsUpdating { log.Printf("Your database schema needs to be updated. The application will continue to run, but you may encounter errors.\n") } _ = db routes := routes.Routes() fmt.Println("Listening on localhost:8999") http.ListenAndServe("localhost:8999", httpx.Log(httpx.WithCtx(db, routes))) }