golang配置环境变量和安装vscode插件

此昵称已被狗抢占 · · 1574 次点击 · · 开始浏览    
这是一个创建于 的文章,其中的信息可能已经有所发展或是发生改变。

windows配置步骤
  • step1:新建D:/mygo文件夹存放第三方库,为了防止污染go源码,官方的设定
  • step2:编辑系统环境变量
    1.新建 GOROOT D:/go
    2.新建 GOPATH D:/mygo
    3.新建 GOBIN D:/mygo/bin
    4.在path末端加上 %GOROOT%/bin
  • step3: 去官网https://golang.google.cn/dl/下载gox.xx.x.windows-amd64.zip解压到GOROOT
  • step4:vscode添加go插件
  • step5:安装go插件依赖的工具

执行最下方安装脚本是发生这种以下情况下最直接的解决方法,开始时尝试过设置代理的方法,但依旧无法解决

Fetching https://golang.org/x/tools/go/gcexportdata?go-get=1
https fetch failed: Get https://golang.org/x/tools/go/gcexportdata?go-get=1: dial tcp 216.239.37.1:443: connectex: A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond.
package golang.org/x/tools/go/gcexportdata: unrecognized import path "golang.org/x/tools/go/gcexportdata" (https fetch: Get https://golang.org/x/tools/go/gcexportdata?go-get=1: dial tcp 216.239.37.1:443: connectex: A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond.)

安装脚本

mkdir D:/mygo/src
cd D:/mygo/src
git clone https://github.com/golang/tools.git ./golang.org/x/tools
git clone https://github.com/golang/lint.git ./golang.org/x/lint
git clone https://github.com/mdempsky/gocode.git ./github.com/mdempsky/gocode
git clone https://github.com/karrick/godirwalk.git ./github.com/karrick/godirwalk
git clone https://github.com/pkg/errors.git ./github.com/pkg/errors
git clone https://github.com/golang/xerrors.git ./golang.org/x/xerrors
git clone https://github.com/golang/sync.git ./golang.org/x/sync
git clone https://github.com/skratchdot/open-golang.git ./github.com/skratchdot/open-golang
git clone https://github.com/uudashr/gopkgs.git ./github.com/uudashr/gopkgs
git clone https://github.com/ramya-rao-a/go-outline.git ./github.com/ramya-rao-a/go-outline
git clone https://github.com/acroca/go-symbols.git ./github.com/acroca/go-symbols
git clone https://github.com/go-delve/delve.git ./github.com/go-delve/delve
git clone https://github.com/stamblerre/gocode.git ./github.com/stamblerre/gocode
git clone https://github.com/rogpeppe/godef.git ./github.com/rogpeppe/godef
git clone https://github.com/cweill/gotests.git ./github.com/cweill/gotests
git clone https://github.com/fatih/gomodifytags.git ./github.com/fatih/gomodifytags
git clone https://github.com/josharian/impl.git ./github.com/josharian/impl
git clone https://github.com/davidrjenni/reftools.git ./github.com/davidrjenni/reftools
git clone https://github.com/haya14busa/goplay.git ./github.com/haya14busa/goplay
git clone https://github.com/godoctor/godoctor.git ./github.com/godoctor/godoctor

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/rogpeppe/godef
go install golang.org/x/tools/cmd/goimports
go install golang.org/x/lint/golint
go install golang.org/x/tools/cmd/gopls
go install github.com/cweill/gotests/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
go install golang.org/x/tools/gopls

有疑问加站长微信联系(非本文作者)

本文来自:简书

感谢作者:此昵称已被狗抢占

查看原文:golang配置环境变量和安装vscode插件

入群交流(和以上内容无关):加入Go大咖交流群,或添加微信:liuxiaoyan-s 备注:入群;或加QQ群:692541889

1574 次点击  ∙  1 赞  
加入收藏 微博
暂无回复
添加一条新回复 (您需要 登录 后才能回复 没有账号 ?)
  • 请尽量让自己的回复能够对别人有帮助
  • 支持 Markdown 格式, **粗体**、~~删除线~~、`单行代码`
  • 支持 @ 本站用户;支持表情(输入 : 提示),见 Emoji cheat sheet
  • 图片支持拖拽、截图粘贴等方式上传