rog-golang-buddies / golang-template-repository

Kickstarter repository for a golang service
Apache License 2.0
17 stars 7 forks source link

Add a way to cross-compile builds for multiple OS and Architectures #63

Closed pmoieni closed 2 years ago

pmoieni commented 2 years ago

since we don't know which user is using which OS, then executing go build or make build go will build the binary for that specific OS and Architecture. to avoid that and cross-compile the code we can use GOOS and GOARCH environment variables inside the MAKEFILE.

examples

Windows 64-bit: GOOS=windows GOARCH=amd64 go build -o bin/app-amd64.exe app.go

Windows 32-bit: GOOS=windows GOARCH=386 go build -o bin/app-386.exe app.go

haani-niyaz commented 2 years ago

@pmoieni The next release of the template repo will include https://goreleaser.com/. OS/Arch specific binaries will be published on "release". A cli is also available if local testing is necessary. Hope this covers your requirement.

pmoieni commented 2 years ago

@haani-niyaz yes. That looks good.

haani-niyaz commented 2 years ago

Fixed in v0.2.0. Closing.