1. 编译
go build -ldflags "-s -w" xxx.go
upx -9 ./xxx_min ./xxx
注:upx可以将程序压缩,如果没有upx命令,则进行安装:
mac
brew install upx
mac
CGO_ENABLED=0 GOOS=darwin GOARCH=amd64 go build -o morning_darwin_min -ldflags "-s -w" *.go
linux
CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -o dist/morning_linux -ldflags "-s -w" *.go
window
CGO_ENABLED=0 GOOS=windows GOARCH=amd64 go build -o dist/morning.exe -ldflags "-s -w" *.go