undefined

Golang支持交叉编译,在一个平台上生成然后再去另外一个平台去执行。

交叉编译

1. Mac下编译,Linux或者Windows下去执行

1
2
3
4
# linux 下去执行
CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build main.go
# Windows 下去执行
CGO_ENABLED=0 GOOS=windows GOARCH=amd64 go build main.go

2. Linux下编译,Mac或者Windows下去执行

1
2
3
4
# Mac  下去执行
CGO_ENABLED=0 GOOS=darwin GOARCH=amd64 go build main.go
# Windows 下执行
CGO_ENABLED=0 GOOS=windows GOARCH=amd64 go build main.go

查看更多