Go的交叉编译

Go语言的交叉编译在不同的系统打包编译的命令

1
2
#-o:指定编译后的二进制包名称
GOOS=linux GOARCH=amd64 go build -o app main.go
1
2
#编译windows的exe文件
CGO_ENABLED=0 GOOS=windows GOARCH=amd64 go build -o test.exe main.go