ubuntu下建立golang的build脚本

在不在os中设置gopath,goroot的情况下

建立build.sh文件,文件内容如下:

export GOARCH="386"
export GOBIN="/home/looler/下载/go/bin"
export GOEXE=""
export GOHOSTARCH="386"
export GOHOSTOS="linux"
export GOOS="linux"
export GOPATH="/home/looler/go:/home/looler/下载/goproject"
export GORACE=""
export GOROOT="/home/looler/下载/go"
export GOTOOLDIR="/home/looler/下载/go/pkg/tool/linux_386"
export GCCGO="gccgo"
export GO386=""
export CC="gcc"
export GOGCCFLAGS="-fPIC -m32 -pthread -fmessage-length=0 -fdebug-prefix-map=/tmp/go-build128906296=/tmp/go-build -gno-record-gcc-switches"
export CXX="g++"
export CGO_ENABLED="1"
export PKG_CONFIG="pkg-config"
export CGO_CFLAGS="-g -O2"
export CGO_CPPFLAGS=""
export CGO_CXXFLAGS="-g -O2"
export CGO_FFLAGS="-g -O2"
export CGO_LDFLAGS="-g -O2"

$GOBIN/go build -buildmode=plugin hello.go

原文地址:https://www.cnblogs.com/coolyylu/p/7001653.html