thatisuday / go-cross-build

GitHub Action to build Go (Golang) modules.
https://itnext.io/how-to-set-up-github-workflows-and-create-github-actions-using-docker-3a5ba7ec0988
37 stars 29 forks source link

adding cgo parameter flag #7

Open mplachter opened 3 years ago

mplachter commented 3 years ago

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 commented 3 years ago

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.