go-gorm / sqlite

GORM sqlite driver
MIT License
179 stars 184 forks source link

feat: use pure-go implementation when cgo is disabled #161

Open aymanbagabas opened 1 year ago

aymanbagabas commented 1 year ago

This implements a pure-go alternative driver whenever CGO_ENABLED=0

Related: https://github.com/go-gorm/sqlite/pull/93 Fixes: https://github.com/go-gorm/sqlite/issues/35 Fixes: https://github.com/go-gorm/sqlite/issues/72 Fixes: https://github.com/go-gorm/sqlite/issues/77 Fixes: https://github.com/go-gorm/sqlite/issues/160

What did this pull request do?

This PR uses a pure-go implementation of SQLite using https://gitlab.com/cznic/sqlite whenever CGO_ENABLED is disabled, and uses https://github.com/mattn/go-sqlite3 when CGO is enabled.

User Case Description

As shown in https://github.com/go-gorm/sqlite/issues/77 https://github.com/go-gorm/sqlite/issues/72 https://github.com/go-gorm/sqlite/pull/93 https://github.com/go-gorm/sqlite/issues/35, sometime CGO is inconvenient.

ncruces commented 1 year ago

DSNs are different between drivers. Having code that behaves silently behaves significantly differently because the C compiler toolchain is not installed is a bad idea, IMO.