go-cross-build icon indicating copy to clipboard operation
go-cross-build copied to clipboard

adding cgo parameter flag

Open mplachter opened this issue 3 years ago • 1 comments

Go by default will build with CGO enabled when building on native systems where it is expected to work. https://pkg.go.dev/cmd/cgo#:~:text=The%20cgo%20tool%20is%20enabled,to%200%20to%20disable%20it.

I would like to add a parameter flag which will disable CGO when building no matter if it could be supported natively.

This is useful when building artifacts that will not run on systems that will not have the c bindings present for example docker containers running binaries.

mplachter avatar Jul 27 '21 16:07 mplachter

Added second commit can squash later.

First commit actually changed the default behavior of go build as it would either set CGO to be on or off where in the default it is only on for the binary if the system building it matches the build architecture and system.

mplachter avatar Jul 27 '21 21:07 mplachter