windows go环境
环境变量
GOROOT = C:\Go\
Path = C:\Go\bin
GOPATH = D:\goproject 工作目录 , go项目的工作路径
linux go环境
安装配置
wget https://studygolang.com/dl/golang/go1.9.2.linux-amd64.tar.gz
tar xf go1.9.2.linux-amd64.tar.gz -C /usr/local/
vim /etc/profile.d/go.sh
export GOROOT=/usr/local/go
export PATH=$PATH:/usr/local/go/bin
export GOPATH=/opt/goproject
. /etc/profile
测试
hello.go
package main
import "fmt"
func main() {
fmt.Println("hello world")
}
go run运行
go run hello.go
编译
go build hello.go
二进制运行
./hello
vscode插件
GOPATH路径下安装插件
D:\goproject
go get github.com/nsf/gocode
go get github.com/uudashr/gopkgs/cmd/gopkgs
go get github.com/ramya-rao-a/go-outline
go get github.com/acroca/go-symbols
go get golang.org/x/tools/cmd/guru
go get golang.org/x/tools/cmd/gorename
go get github.com/fatih/gomodifytags
go get github.com/haya14busa/goplay/cmd/goplay
go get github.com/josharian/impl
go get github.com/rogpeppe/godef
go get sourcegraph.com/sqs/goreturns
go get github.com/golang/lint/golint
go get github.com/cweill/gotests
go get github.com/derekparker/delve/cmd/dlv
说明:以上操作如果失败,则执行以下
cd $GOPATH/src/github.com/golang
git clone https://github.com/golang/tools.git
git下载完成后,把$GOPATH/src/github.com/golang/tools目录下的所有文件拷贝到$GOPATH/src/golang.org/x/tools下
go install github.com/nsf/gocode
go install github.com/uudashr/gopkgs/cmd/gopkgs
go install github.com/ramya-rao-a/go-outline
go install github.com/acroca/go-symbols
go install golang.org/x/tools/cmd/guru
go install golang.org/x/tools/cmd/gorename
go install github.com/fatih/gomodifytags
go install github.com/haya14busa/goplay/cmd/goplay
go install github.com/josharian/impl
go install github.com/rogpeppe/godef
go install sourcegraph.com/sqs/goreturns
go install github.com/golang/lint/golint
go install github.com/cweill/gotests
go install github.com/derekparker/delve/cmd/dlv