Cannot properly build a simple sqlite application
Opened this issue ยท 9 comments
Hey everyone!
I must first state that I have never used this package before, but I had some experience with SQLite in other languages.
I am working on my MacOS (Sequoia - M3 Pro), using VsCode. Everything is up to date, always.
I wrote my very simple code:
package main
import (
"log"
_ "github.com/mattn/go-sqlite3"
)
func main() {
log.Println("Hello, World!")
}
I am unable to debug my app in VsCode with the following lauch.json
:
{
"version": "0.2.0",
"configurations": [
{
"type": "go",
"name": "Start hello",
"request": "launch",
"mode": "auto",
"cwd": "${workspaceFolder}",
"program": "${workspaceFolder}/cmd/hello"
}
]
}
I went and tried to debug manually, but then I had issues when trying to create an executable from it ๐ข
I am able to run this code with the go run ./cmd/hello
command, however, I have difficulties when I try to create executable from it. I tried the following commands:
go build ./cmd/hello
CGO_ENABLED=1 go build ./cmd/hello
CGO_ENABLED=1 go build -tags "darwin arm64" ./cmd/hello
CGO_ENABLED=1 go build -tags "darwin arm64 libsqlite3" ./cmd/hello
None of that seems to result an executable that works.
If I try to run the executable from the vs-code integrated command line, the executable hangs, won't respond to ctrl+c
, in separate terminals, the executable crashes.
Crash report attached.
I think i will have other issues once I need to dockerize my app, but that's for another day I think (cross platform builds for amd64/arm64 linux).
Do you have any good tips on this?
crashreport.txt
What version of Go are you using? What version of this library are you using? What version of which C compiler are you using?
Are you saying that go build itself hangs, or the binary that it produces hangs?
Versions:
go version go1.22.5 darwin/arm64
github.com/mattn/go-sqlite3 v1.14.23
gcc -v 668ms
Apple clang version 16.0.0 (clang-1600.0.26.3)
Target: arm64-apple-darwin24.0.0
Thread model: posix
InstalledDir: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin
The produced binary hangs when trying to start it.
Your crash report suggests it is getting killed because the code was not signed. That seems like a macos configuration issue of some kind?
+1
I'm having exactly same issue, also on MacOS, did you was able to work around this @IceBjerg
No workaround unfortunately.
And I am also being able to build the app without the import being in it, so I don't think it's MacOS configuration issue.
I encountered a similar issue and resolved it temporarily by manually code signing with codesign --sign - ./main
. However, I have to repeat this process every time I build, which doesn't seem like a proper solution.
I had this same problem (specifically, binaries where I had included go-sqlite3
were being killed for codesigning reason). Doing things like clearing the go module and build cache did not help.
I ended up resolving it by uninstalling and reinstalling go from brew (brew uninstall go
and brew install go
).
That's an unfortunately superstitious thing to have to do, but I haven't had this since. Given what feels like a recent spike in these reports for mac users here, I wonder if there's something weird that happened to brew installs of go and clang interacting with each other.
I recently updated to Mac OS 15.0.1 Sequoia and started experience this issue as well. Running codesign --sign - ./main
does make it run. Doing go run main.go
also works.
I did not install go
from homebrew but instead manually installed it in /usr/local/go
.
Switching to using Homebrew go resolved the issue.