VSCode 搭建Go开发环境详细步骤

1 安装go插件时报错

可以直接看步骤4!!!

Installing 8 tools at /home/deepin/Documents/workspace/go//bin
  gocode
  go-outline
  go-symbols
  guru
  gorename
  gocode-gomod
  goreturns
  golint

Installing github.com/mdempsky/gocode FAILED
Installing github.com/ramya-rao-a/go-outline FAILED
Installing github.com/acroca/go-symbols FAILED
Installing golang.org/x/tools/cmd/guru FAILED
Installing golang.org/x/tools/cmd/gorename FAILED
Installing github.com/stamblerre/gocode FAILED
Installing github.com/sqs/goreturns FAILED
Installing golang.org/x/lint/golint FAILED

8 tools failed to install.

2 安装所有github.com开头的包

进入$GOPATH/src目录。安装所有github.com开头的包:

  • Installing github.com/mdempsky/gocode FAILED
    $GOPATH/src目录下新建github.com/mdempsky/目录,然后在生成的目录下执行如下命令:
git clone https://github.com/mdempsky/gocode
  • Installing github.com/ramya-rao-a/go-outline FAILED
    $GOPATH/src目录下新建github.com/ramya-rao-a/目录,然后在生成的目录下执行如下命令:
git clone https://github.com/ramya-rao-a/go-outline
  • Installing github.com/acroca/go-symbols FAILED
    $GOPATH/src目录下新建github.com/acroca/目录,然后在生成的目录下执行如下命令:
git clone https:github.com/acroca/go-symbols
  • Installing github.com/stamblerre/gocode FAILED
    $GOPATH/src目录下新建github.com/stamblerre/目录,然后在生成的目录下执行如下命令:
git clone https:github.com/stamblerre/gocode
  • Installing github.com/sqs/goreturns FAILED
    $GOPATH/src目录下新建github.com/sqs/目录,然后在生成的目录下执行如下命令:
git clone https:github.com/sqs/goreturns

3 安装所有golang.org开头的包

  • Installing golang.org/x/lint/golint FAILEDD
    $GOPATH/src目录下新建golang.org/x/目录,然后在生成的目录下执行如下命令:
git clone https://github.com/golang/lint
  • Installing golang.org/x/tools/cmd/guru FAILED
    $GOPATH/src目录下新建github.com/x/目录,然后在生成的目录下执行如下命令:
git clone https://github.com/golang/tools.git 
  • Installing golang.org/x/tools/cmd/gorename FAILED
    上一步已经安装了tools,这里不用再装一次了。

4 简化上面的步骤

由于所有github.com开头的包都是可以下载的,只是在安装的时候会依赖其它包,如golang.org包,所以才会安装失败,所以我们只需要安装golang.org包就可以了。

Installing golang.org/x/lint/golint FAILED
Installing golang.org/x/tools/cmd/guru FAILED
Installing golang.org/x/tools/cmd/gorename FAILED

我们在$GOPATH/src目录下新建github.com/x/目录,然后在生成的目录下执行如下命令:

git clone https://github.com/golang/lint

git clone https://github.com/golang/tools.git 

5 安装

当所需要的包都安装完成后,执行下面的命令:

go install github.com/mdempsky/gocode
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/stamblerre/gocode 
go install github.com/sqs/goreturns 
go install golang.org/x/lint/golint 

如果上面的命令执行不报错,那么插件就安装好可以愉快的开发了,如果还报错,就去安装对应的所需要的包~~

发布了78 篇原创文章 · 获赞 58 · 访问量 3万+

猜你喜欢

转载自blog.csdn.net/qq122516902/article/details/91856018