在网上找了一些例子,为了应用方便,自己简单记录一下。前提条件:配置GOPATH、GOBIN、PATH
一、检查环境配置,很重要!
Ubuntu16.04下配置(~/.bashrc)如下:
export GOPATH=/home/user/go
export GOBIN=$GOPATH/bin
export PATH=$PATH:${GOPATH//://bin:}/bin
查看go环境配置情况:
user@user-OptiPlex-9010:~/go/src/pp$ go env
GOARCH="amd64"
GOBIN="/home/user/go/bin"
GOEXE=""
GOHOSTARCH="amd64"
GOHOSTOS="linux"
GOOS="linux"
GOPATH="/home/user/go"
GORACE=""
GOROOT="/usr/lib/go-1.6"
GOTOOLDIR="/usr/lib/go-1.6/pkg/tool/linux_amd64"
GO15VENDOREXPERIMENT="1"
CC="gcc"
GOGCCFLAGS="-fPIC -m64 -pthread -fmessage-length=0"
CXX="g++"
CGO_ENABLED