1. 在windows下打包
1.1 打包成windows可执行文件
set CGO_ENABLED=0
set GOOS=windows
set GOARCH=amd64
go build -o demo-windows.exe
1.2 打包成mac可执行文件
set CGO_ENABLED=0
set GOOS=darwin
set GOARCH=amd64
go build -o demo-mac
1.3 打包成linux可执行文件
set CGO_ENABLED=0
set GOOS=linux
set GOARCH=amd64
go build -o demo-linux
2. 在Mac下打包
# linux
CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -o demo-linux
# mac
CGO_ENABLED=0 GOOS=darwin GOARCH=amd64 go build -o demo-mac
# windows
CGO_ENABLED=0 GOOS=windows GOARCH=amd64 go build -o demo-windows.exe
3. 在Linux下打包
# linux
CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -o demo-linux
# mac
CGO_ENABLED=0 GOOS=darwin GOARCH=amd64 go build -o demo-mac
# windows
CGO_ENABLED=0 GOOS=windows GOARCH=amd64 go build -o demo-windows.exe
评论区