交叉编译

Windows环境

# darwin
CGO_ENABLED=0 GOOS=darwin GOARCH=amd64 go build main.go

# linux
# 若使用sqliet则CGO_ENABLED=1
CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build main.go

Linux环境下

# darwin
CGO_ENABLED=0 GOOS=darwin GOARCH=amd64 go build main.go

# windows
CGO_ENABLED=0 GOOS=windows GOARCH=amd64 go build main.go

压缩编译后的文件

去除调试信息

# 添加 -w
go build -ldflags -w test.go

加壳压缩

# 项目地址
# https://github.com/upx/upx/releases

# windows压缩
upx.exe -9 -k “test.exe”

# linux压缩
upx -9 -k test
最后修改:2023 年 10 月 16 日
如果觉得我的文章对你有用,请随意赞赏