this repo has no description
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

use volume

+5 -12
+5 -12
database.go
··· 5 5 "fmt" 6 6 "log" 7 7 "log/slog" 8 - "os" 9 8 10 9 "github.com/bugsnag/bugsnag-go/v2" 11 10 _ "github.com/glebarez/go-sqlite" 11 + ) 12 + 13 + const ( 14 + dbfile = "./data/sqlite-database.db" 12 15 ) 13 16 14 17 func db() { 15 - os.Remove("sqlite-database.db") // I delete the file to avoid duplicated records. 16 - // SQLite is a file based database. 17 - 18 - log.Println("Creating sqlite-database.db...") 19 - file, err := os.Create("sqlite-database.db") // Create SQLite file 20 - if err != nil { 21 - bugsnag.Notify(fmt.Errorf("create db: %w", err)) 22 - return 23 - } 24 - file.Close() 25 18 log.Println("sqlite-database.db created") 26 19 27 - sqliteDatabase, _ := sql.Open("sqlite", "./sqlite-database.db") // Open the created SQLite File 20 + sqliteDatabase, _ := sql.Open("sqlite", dbfile) // Open the created SQLite File 28 21 defer sqliteDatabase.Close() 29 22 30 23 createTable(sqliteDatabase)