golang开发笔记

go build 不同系统

Mac下编译Linux, Windows平台的64位可执行程序:


CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build test.go
CGO_ENABLED=0 GOOS=windows GOARCH=amd64 go build test.go
Linux下编译Mac, Windows平台的64位可执行程序:


CGO_ENABLED=0 GOOS=darwin GOARCH=amd64 go build test.go
CGO_ENABLED=0 GOOS=windows GOARCH=amd64 go build test.go
Windows下编译Mac, Linux平台的64位可执行程序:


SET CGO_ENABLED=0
SET GOOS=darwin3
SET GOARCH=amd64
go build test.go


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

你可能感兴趣的:(golang开发笔记)