今天把mac测试的gin demo 编译下放到centos 上跑一下 编译完了执行一直报错

go cannot execute binary file

 

 

 交叉编译的环境变量也设置了,就是不行

CGO_ENABLED=0 GOOS=linux GOARCH=amd64

原来环境变量设置需要跟go build 在一条命令中执行。如下

CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -a  -o afei1 afei.go

这样生成的二进制文件再放到服务器上就可以执行了

go cannot execute binary file

 

相关文章: