-
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Proposal: sub-packages to enable optional features #1134
base: master
Are you sure you want to change the base?
Conversation
Have you tested this? AFAIK the |
Yes, I have tested this and it works correctly. AFAIU the cgo flags are not package-scoped, they are module-scoped. See: golang/go#40041 |
I just ran a simplified test case. From what I can tell, the cgotest/go.mod module cgotest
go 1.18 cgotest/main.go package main
import _ "cgotest/subpackage"
/*
#include <sqlite3.h>
*/
import "C"
func main() {
C.sqlite3_open_v2(nil, nil, 0, nil)
} cgotest/subpackage/c.go package subpackage
/*
#cgo LDFLAGS: -lsqlite3
*/
import "C"
|
On my system this builds just fine (and fails at runtime because of the
|
Okay, based on further testing, it seems this behavior changed in Go 1.19. However, it was not mentioned in the release notes. And I'm not sure if it was intentional, since the cgo docs make no mention of modules or sub-packages. I'm going to file an issue with the Go authors for this. In the meantime, I don't think we can accept this change, since this module intends to support Go 1.18. |
Note, the result of this discussion is at golang/go#58438 (comment). |
In the end I opted to bundle FTS5 in a separate Go package: https://git.sr.ht/~emersion/go-sqlite3-fts5 |
A common pain point when using go-sqlite3 is that enabling optional features requires adding a build tag to all
go
command invocations. For instance, when a program depends on FTS5, it's no longer possible to rungo build
,go test
, etc as usual. End users need to explicitly add-tags sqlite_fts5
every time.Here is a proposal to improve this. A new
fts5
sub-package is introduce. Any program which depends on FTS5 can import it to turn on FTS5:What do you think?