Golang交叉编译主要依赖几个参数:GOOS、GOARCH和CGO_ENABLED。
参数 | 作用 |
---|---|
GOOS | 交叉编译的OS |
GOARCH | 交叉编译的CPU架构 |
CGO_ENABLED | 设置为0时,编译出的二进制是静态的,也就是说没有外部的依赖。 |
编译在arm64的linux环境运行的程序:
CGO_ENABLED=0 GOOS=linux GOARCH=arm64 go build -o bin/operator cmd/operator/main.go
Golang交叉编译主要依赖几个参数:GOOS、GOARCH和CGO_ENABLED。
参数 | 作用 |
---|---|
GOOS | 交叉编译的OS |
GOARCH | 交叉编译的CPU架构 |
CGO_ENABLED | 设置为0时,编译出的二进制是静态的,也就是说没有外部的依赖。 |
编译在arm64的linux环境运行的程序:
CGO_ENABLED=0 GOOS=linux GOARCH=arm64 go build -o bin/operator cmd/operator/main.go