Skip to content

Commit

Permalink
Switch databse driver to 'modernc.org/sqlite'
Browse files Browse the repository at this point in the history
This modification removes the dependency on CGO during compilation
and makes the resulting binary more portable across distributions
(e.g., runs on Ubuntu 18.04 despite being built on Ubuntu 20.04) as
well as making it easier to support other OSs (i.e., Windows).

Fixes #37
  • Loading branch information
John E. Rollinson committed Feb 28, 2022
1 parent 64018ce commit bbd7d4a
Show file tree
Hide file tree
Showing 3 changed files with 175 additions and 5 deletions.
4 changes: 2 additions & 2 deletions cmgr/database.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import (
"reflect"

"github.com/jmoiron/sqlx"
_ "github.com/mattn/go-sqlite3"
_ "modernc.org/sqlite"
)

const schemaQuery string = `
Expand Down Expand Up @@ -179,7 +179,7 @@ func (m *Manager) initDatabase() error {
dbPath = "cmgr.db"
}

db, err := sqlx.Open("sqlite3", dbPath+"?_fk=true")
db, err := sqlx.Open("sqlite", dbPath+"?_pragma=foreign_keys(1)")
if err != nil {
m.log.errorf("could not open database: %s", err)
return err
Expand Down
3 changes: 2 additions & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,10 @@ require (
github.com/docker/go-connections v0.4.0
github.com/docker/go-units v0.4.0
github.com/jmoiron/sqlx v1.3.4
github.com/mattn/go-sqlite3 v1.14.9
github.com/morikuni/aec v1.0.0 // indirect
github.com/yuin/goldmark v1.4.2
golang.org/x/net v0.0.0-20220127200216-cd36cc0744dd // indirect
google.golang.org/grpc v1.44.0 // indirect
gopkg.in/yaml.v2 v2.4.0
modernc.org/sqlite v1.14.6
)
Loading

0 comments on commit bbd7d4a

Please sign in to comment.