Skip to content

Commit 6d58826

Browse files
committed
*: fix non-cgo builds
The package offers very little runtime functionality without CGO but must be able to be depended upon without breaking cross builds. A CI check is added, and two issues are resolved that block non-CGO builds.
1 parent 6cfe794 commit 6d58826

File tree

10 files changed

+26
-7
lines changed

10 files changed

+26
-7
lines changed

.github/workflows/test-sqlite.yml

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,4 +27,7 @@ jobs:
2727
run: go test -v ./...
2828

2929
- name: Race
30-
run: go test -v -race ./...
30+
run: go test -v -race ./...
31+
32+
- name: No CGO build
33+
run: CGO_ENABLED=0 go install ./...

sqlite.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1131,3 +1131,6 @@ type ConnLogger interface {
11311131
// Rollback is called after a rollback statement.
11321132
Rollback()
11331133
}
1134+
1135+
// LogCallback receives SQLite log messages.
1136+
type LogCallback func(code sqliteh.Code, msg string)

sqlite_cgo.go

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,15 @@
11
//go:build cgo
2-
// +build cgo
32

43
package sqlite
54

65
import (
76
"github.com/tailscale/sqlite/cgosqlite"
8-
"github.com/tailscale/sqlite/sqliteh"
97
)
108

119
func init() {
1210
Open = cgosqlite.Open
1311
}
1412

15-
// LogCallback receives SQLite log messages.
16-
type LogCallback func(code sqliteh.Code, msg string)
17-
1813
// SetLogCallback sets the global SQLite log callback.
1914
// If callback is nil, logs are discarded.
2015
func SetLogCallback(callback LogCallback) error {

sqlite_cgo_test.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
//go:build cgo
2-
// +build cgo
32

43
package sqlite
54

sqlite_nocgo.go

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
//go:build !cgo
2+
3+
package sqlite
4+
5+
// SetLogCallback sets the global SQLite log callback.
6+
// If callback is nil, logs are discarded.
7+
func SetLogCallback(callback LogCallback) error {
8+
return nil
9+
}

sqlitepool/queryglue.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
//go:build cgo
2+
13
package sqlitepool
24

35
// This file contains bridging functions designed to let users of

sqlitepool/queryglue_test.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
//go:build cgo
2+
13
package sqlitepool
24

35
import (

sqlitepool/sqlitepool.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
//go:build cgo
2+
13
// Package sqlitepool implements a pool of SQLite database connections.
24
package sqlitepool
35

sqlitepool/sqlitepool_test.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
//go:build cgo
2+
13
package sqlitepool
24

35
import (

sqlitepool/util.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
//go:build cgo
2+
13
package sqlitepool
24

35
import (

0 commit comments

Comments
 (0)