#database #development #golang
Turns out there is actually a solution for this.
1brew install FiloSottile/musl-cross/musl-cross
Once you have this installed, you can compile for Linux like this:
CC=x86_64-linux-musl-gcc CXX=x86_64-linux-musl-g++ GOARCH=amd64 GOOS=linux CGO_ENABLED=1 \ go build -ldflags "-linkmode external -extldflags -static"
You can also do the same when you want to cross compile to Windows. The instructions for that can be found here.
If this post was enjoyable or useful for you, please share it! If you have comments, questions, or feedback, you can email my personal email. To get new posts, subscribe use the RSS feed.