我的环境


GOARCH="amd64"

GOBIN=""

GOEXE=""

GOHOSTARCH="amd64"

GOHOSTOS="linux"

GOOS="linux"

GOPATH=""

GORACE=""

GOROOT="/usr/local/go"

GOTOOLDIR="/usr/local/go/pkg/tool/linux_amd64"

GO15VENDOREXPERIMENT=""

CC="gcc"

GOGCCFLAGS="-fPIC -m64 -pthread -fmessage-length=0"

CXX="g++"

CGO_ENABLED="1"

我在我的 mac 上编译并成功执行了二进制文件,然后将它复制到上面显示 go env 的 ubuntu 机器。当我调用 myprog 二进制文件时,我得到


bash: /usr/local/go/bin/myprog: cannot execute binary file: Exec format error