0

I am thinking of purchasing a new macbook pro, but one thing bothers me, which is that I may need to compile the x86 golang binary on this machine and copy it to the other x86 machines, I did some search on Google, and it seems that Go support cross-compile, but anyone has the experience with this before? Can I compile and get a x86-64 golang binary on the m1 macbook pro, which can be runned on the x86-64 machines with system like Ubuntu 20.04?

Thanks.

SSolid2014
  • 11
  • 1
  • 2

1 Answers1

5

I don't think Apple M1 will cause you any problem .
Compilation for Windows :

GOOS=windows GOARCH=amd64 go build hello.go

Compilation for Apple M1 :

GOOS=darwin GOARCH=arm64 go build -o hello-macos-arm64 hello.go

There is a great blog in dev.to . I hope this will be helpful link