Skip to content

SQLite driver's dependency on gcc #7217

Closed as not planned
Closed as not planned
@michal-kapala

Description

@michal-kapala

The problem was mentioned in #6468, gorm.io/driver/sqlite depends on github.com/mattn/go-sqlite3 which is a cgo lib and requires gcc to build a binary.

Reproduction

sqlite3 example.db
go run .
package main

import (
	"fmt"

	"gorm.io/driver/sqlite"
	"gorm.io/gorm"
)

func Init(filename string) (*gorm.DB, error) {
	database, err := gorm.Open(sqlite.Open(filename), &gorm.Config{})
	if err != nil {
		return nil, err
	}
	return database, nil
}

func main() {
	database, err := Init("example.db")
	if database == nil {
		fmt.Println(err)
		return
	}
}

Runtime error

[error] failed to initialize database, got error Binary was compiled with 'CGO_ENABLED=0', go-sqlite3 requires 
cgo to work. This is a stub

Reference issues

Manual workaround can be found at mattn/go-sqlite3#855.

There's a feature request for pure go driver implementation use at go-gorm/sqlite#160

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions