环境变量
C:\Users\zhangzt>go env
set GO111MODULE=on //启用 gomod
set GOARCH=amd64
set GOBIN=
set GOCACHE=C:\Users\zhangzt\AppData\Local\go-build
set GOEXE=.exe
set GOFLAGS=
set GOHOSTARCH=amd64
set GOHOSTOS=windows
set GOOS=windows
set GOPATH=C:\Users\zhangzt\go;C:\Users\zhangzt\go1 --工作目录 可以多个 用;分隔
set GOPROXY=
set GORACE=
set GOROOT=C:\Go --go安装位置
set GOTMPDIR=
set GOTOOLDIR=C:\Go\pkg\tool\windows_amd64
set GCCGO=gccgo //go垃圾回收 gc
set CC=gcc
set CXX=g++
set CGO_ENABLED=1
set GOMOD=
set CGO_CFLAGS=-g -O2
set CGO_CPPFLAGS=
set CGO_CXXFLAGS=-g -O2
set CGO_FFLAGS=-g -O2
set CGO_LDFLAGS=-g -O2
set PKG_CONFIG=pkg-config
set GOGCCFLAGS=-m64 -mthreads -fno-caret-diagnostics -Qunused-arguments -fmessage-length=0 -fdebug-prefix-map=C:\Users\zhangzt\AppData\Local\Temp\go-build736731342=/tmp/go-build -gno-record-gcc-switches
Go项目目录结构 (gopath模式)
F:\GOPROJECT --工作目录
├─bin --go编译可执行文件存放路径
├─pkg --go编译包时,生成的.a文件存放路径
└─src --源码路径。按照golang默认约定,go run,go install等命令的当前工作路径(即在此路径下执行上述命令)。
├─myproject.com --域名 目录结构为 src ->域名->具体项目-> 源码
│ └─project --项目
└─myproject1.com
VSCode安装后,安装中文和go插件,然后执行以下命令
- go get -u -v github.com/nsf/gocode
- go get -u -v github.com/rogpeppe/godef
克隆 2个 git clone http s://github.com/golang/tools.git git clone http s://github.com/golang/lint.git 到 src/golang.org/x 目录下
go get golang.org/x/lint/golint
go get -u -v github.com/lukehoban/go-find-references
go get -u -v github.com/lukehoban/go-outline
go get -u -v sourcegraph.com/sqs/goreturns
go get -u -v golang.org/x/tools/cmd/gorename
go get -u -v github.com/tpng/gopkgs
go get -u -v github.com/newhook/go-symbols