1.下载 Golang 的 Windows 版本并安装
官网:https://golang.org/dl
安装后,CMD命令行添加
go env -w GO111MODULE=on GOPROXY=https://goproxy.cn,https://goproxy.io,direct
2.下载源代码并解压
进入源码目录,CMD命令行添加执行
env:CGO_ENABLED=0 go build -o x.exe -trimpath -ldflags "-s -w" ./main go build -o wx.exe -trimpath -ldflags "-s -w -H windowsgui" ./main go build -o xctl.exe -trimpath -ldflags "-s -w" -tags confonly ./infra/control/main
3. 编译ARM版
env:CGO_ENABLED=0 env:GOOS="linux" env:GOARCH="arm64" # 64位架构 ARMv8 env:GOARCH="arm" # 32位架构 env:GOARM=5 # ARMv5-ARMv7 32位架构 go build -o x -trimpath -ldflags "-s -w" ./main go build -o xctl -trimpath -ldflags "-s -w" -tags confonly ./infra/control/main
4. 编译linux版
env:CGO_ENABLED=0 env:GOOS="linux" env:GOARCH="amd64" go build -o x -trimpath -ldflags "-s -w" ./main go build -o xctl -trimpath -ldflags "-s -w" -tags confonly ./infra/control/main
go tool dist list 查看所有支持的系统与架构
https://github.com/golang/go/wiki/GoArm
https://github.com/golang/go/tree/master/src/cmd/go/testdata/script
此处评论已关闭