https://ithelp.ithome.com.tw/articles/10225188

在Windows上編譯

To MacOs

  
SET CGO_ENABLED=0  
SET GOOS=darwin  
SET GOARCH=amd64  
go build main.go  

To Linux

  
SET CGO_ENABLED=0  
SET GOOS=linux  
SET GOARCH=amd64  
go build main.go  

To Windows ???

  
go build main.go  

在Linux上編譯

  
CGO_ENABLED=0 GOOS=darwin GOARCH=amd64 go build main.go  

  
CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build main.go  

  
CGO_ENABLED=0 GOOS=windows GOARCH=amd64 go build main.go