go build 多平台构建
Linux
GOOS=linux GOARCH=amd64 CGO_ENABLED=0 go build main.go
GOOS=linux GOARCH=amd64 CGO_ENABLED=0 go build -ldflags="-w -s" main.go
注意:-ldflags="-w -s"
会去除 DWARF调试信息
、符号信息
macOS
GOOS=darwin GOARCH=amd64 CGO_ENABLED=1 go build main.go
GOOS=darwin GOARCH=amd64 CGO_ENABLED=1 go build -ldflags="-w -s" main.go
Windows
GOOS=windows GOARCH=amd64 CGO_ENABLED=0 go build main.go
GOOS=windows GOARCH=amd64 CGO_ENABLED=0 go build -ldflags="-w -s" main.go