Go_安装与配置

Go:https://studygolang.com/dl                                   Go环境
Git:https://git-scm.com/download/                             Go插件
VS CODE:https://code.visualstudio.com/                      Go编辑器
GoIDE:https://sourceforge.net/projects/liteide/files/   Go编辑器

1、下载并安装Go
2、配置环境变量GOPATH和GOROOT
3、打开命令提示符(cmd.exe)输入 go version 查看是否安装成功
4、下载并安装vs code程序
5、在vs code中安装Go语言插件
    4.1、选择extensions,搜索Chinese (Simplified) Language Pack for Visual Studio Code 点击安装进行汉化
    4.2、选择extensions,搜索Go 点击安装安装后vs code即可支持Go语言的开发,
    4.3、选择extensions,搜索Code Runner 点击安装可快捷运行代码程序
    4.4、需要安装Go工具,参考
6、在vs code中选择文件新建保存为.go文件 输入代码:
package main
import "fmt"
func main() {
    fmt.Printf("hello, world\n")
}
运行代码即可在输出窗口看到结果hello world
7、也可下载GoIDE 下载解压后无需安装打开liteide\bin 双击liteide.exe即可运行

 

注:在安装时,安装路径不要出现中文名。

1、VS CODE 配置GO插件
cd $env:GOPATH
cd src
mkdir golang.org
cd golang.org
mkdir x
cd x

git clone https://github.com/golang/lint.git E:/Gospace/src/golang.org/x/lint
git clone https://github.com/golang/net.git E:/Gospace/src/golang.org/x/net
git clone https://github.com/golang/tools.git E:/Gospace/src/golang.org/x/tools
git clone https://github.com/golang/crypto.git E:/Gospace/src/golang.org/x/crypto

go get -u -v github.com/golang/tools
go get -u -v github.com/golang/lint
go get -u -v github.com/golang/net
go get -u -v github.com/nsf/gocode
go get -u -v github.com/rogpeppe/godef
go get -u -v github.com/lukehoban/go-outline
go get -u -v github.com/sqs/goreturns
go get -u -v github.com/tpng/gopkgs
go get -u -v github.com/uudashr/gopkgs/cmd/gopkgs  
go get -u -v golang.org/x/tools/cmd/guru  
go get -u -v golang.org/x/tools/cmd/gorename  
go get -u -v github.com/go-delve/delve/cmd/dlv  
go get -u -v github.com/zmb3/gogetdoc  
go get -u -v golang.org/x/lint/golint  
go get -u -v github.com/fatih/gomodifytags  
go get -u -v github.com/josharian/impl  
go get -u -v github.com/davidrjenni/reftools/cmd/fillstruct  
go get -u -v github.com/haya14busa/goplay/cmd/goplay  
go get -u -v github.com/godoctor/godoctor
go get -u -v github.com/newhook/go-symbols 
go get -u -v github.com/cweill/gotests

go install github.com/mdempsky/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/go-delve/delve/cmd/dlv  
go install github.com/stamblerre/gocode  
go install github.com/zmb3/gogetdoc  
go install github.com/sqs/goreturns  
go install golang.org/x/lint/golint  
go install github.com/cweill/gotests/...  
go install github.com/fatih/gomodifytags  
go install github.com/josharian/impl  
go install github.com/davidrjenni/reftools/cmd/fillstruct  
go install github.com/haya14busa/goplay/cmd/goplay  
go install github.com/godoctor/godoctor 

2、VS CODE 配置GO环境变量
文件 -> 首选项 -> 工作区设置.vscode/settings.json文件


    //go
    "go.docsTool": "gogetdoc",
    "go.useLanguageServer": true,
    "window.zoomLevel": 1,    
    "go.autocompleteUnimportedPackages": true,   
    "go.gocodePackageLookupMode": "go",
    "go.gotoSymbol.includeImports": true,
    "go.useCodeSnippetsOnFunctionSuggest": true,
    "go.inferGopath": true,  
    "go.useCodeSnippetsOnFunctionSuggestWithoutType": true, 
    // Specifies the GOPATH to use when no environment variable is set.
    "go.gopath": "E:/Gospace",
    // Specifies the GOROOT to use when no environment variable is set.
    "go.goroot": "E:/Go",     

}

你可能感兴趣的:(Go)