实验环境为windows,Golang安装目录为C:Go
血的教训,windows环境中一定在golang编译的时候先停止alibaba pc safe service这个操蛋的进程!!!
首先删除C:Go下的bin和pkg目录,然后进入src目录后,建立以下内容的批处理文件,并执行:

set CGO_ENABLED=0
set GOROOT_BOOTSTRAP=C:/Developer/golang/go1.4.3
set GOPATH=C:/Developer/golang/go1.6.2
::x64块
set GOARCH=amd64
set GOOS=windows
call make.bat --no-clean

set GOOS=linux
call make.bat --no-clean

set GOOS=freebsd
call make.bat --no-clean

set GOOS=darwin
call make.bat --no-clean
::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::

::x86块
set GOARCH=386
set GOOS=windows
call make.bat --no-clean

set GOOS=linux
call make.bat --no-clean

set GOOS=freebsd
call make.bat --no-clean

set GOOS=darwin
call make.bat --no-clean
::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::

::arm块
set GOARCH=arm
set GOOS=linux
call make.bat --no-clean
::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::

set GOARCH=amd64
set GOOS=windows
go get github.com/nsf/gocode
pause

至此,该Go已经可以编译出上述批处理文件中的所有平台的二进制文件了。
请注意go get 时会调用对应的版本控制工具,gocode在github上,所以需要事先安装git客户端,并加入到PATH变量中
在Mac系统中,如果使用homebrew安装的golang,则golang的默认src路径在:
/usr/local/Cellar/go/版本号/libexec/src
同时请注意将上面的批处理中的make.bat全部替换为make.bash,并且将call、set等关键字替换,然后最后export GOOS=darwin而不是windows,贴上我的Mac版本shell脚本,一定要在src目录下哦:

#!/bin/bash
#rm -rf ../bin ../pkg
export GOPATH=/Volumes/ORIGINAL/Developer/golang  #根据实际路径需要修改
export CGO_ENABLED=0

#x64块
export GOARCH=amd64

export GOOS=darwin
./make.bash --no-clean

export GOOS=windows
./make.bash --no-clean

export GOOS=linux
./make.bash --no-clean

export GOOS=freebsd
./make.bash --no-clean

###################################################

#x86块
export GOARCH=386
export GOOS=darwin
./make.bash --no-clean

export GOOS=windows
./make.bash --no-clean

export GOOS=linux
./make.bash --no-clean

export GOOS=freebsd
./make.bash --no-clean

###################################################

#arm块
export GOARCH=arm
export GOOS=linux
./make.bash --no-clean
###################################################

export GOARCH=amd64
export GOOS=darwin
go get github.com/nsf/gocode