VSCode无法安装Go工具怎么解决
来源:Golang技术栈
时间:2023-04-11 15:37:13 299浏览 收藏
积累知识,胜过积蓄金银!毕竟在##column_title##开发的过程中,会遇到各种各样的问题,往往都是一些细节知识点还没有掌握好而导致的,因此基础知识点的积累是很重要的。下面本文《VSCode无法安装Go工具怎么解决》,就带大家讲解一下golang知识点,若是你对本文感兴趣,或者是想搞懂其中某个知识点,就请你继续往下看吧~
问题内容
我尝试在 VSCode 中开始使用 Go。我已经安装了 Go 和 Git,并在 Code 中创建了一个项目,其中包含一个.go
文件。
当我输入一些东西时,VSCode 会警告我golint
缺少类似的工具并提示我安装它们。我点击“全部安装”。
然后控制台显示:
Installing 10 tools gocode gopkgs go-outline go-symbols guru gorename godef goreturns golint gotests Installing gocode SUCCEEDED Installing gopkgs SUCCEEDED Installing go-outline SUCCEEDED Installing go-symbols FAILED Installing guru FAILED Installing gorename FAILED Installing godef SUCCEEDED Installing goreturns FAILED Installing golint FAILED Installing gotests FAILED 6 tools failed to install. go-symbols: Error: Command failed: C:Gobingo.exe get -u -v github.com/newhook/go-symbols github.com/newhook/go-symbols (download) Fetching https://golang.org/x/tools/go/buildutil?go-get=1 Parsing meta tags from https://golang.org/x/tools/go/buildutil?go-get=1 (status code 200) get "golang.org/x/tools/go/buildutil": found meta tag main.metaImport{Prefix:"golang.org/x/tools", VCS:"git", RepoRoot:"https://go.googlesource.com/tools"} at https://golang.org/x/tools/go/buildutil?go-get=1 get "golang.org/x/tools/go/buildutil": verifying non-authoritative meta tag Fetching https://golang.org/x/tools?go-get=1 Parsing meta tags from https://golang.org/x/tools?go-get=1 (status code 200) golang.org/x/tools (download) # cd C:Usersusergosrcgolang.orgxtools; git pull --ff-only fatal: Not a git repository (or any of the parent directories): .git package golang.org/x/tools/go/buildutil: exit status 128 github.com/newhook/go-symbols (download) Fetching https://golang.org/x/tools/go/buildutil?go-get=1 Parsing meta tags from https://golang.org/x/tools/go/buildutil?go-get=1 (status code 200) get "golang.org/x/tools/go/buildutil": found meta tag main.metaImport{Prefix:"golang.org/x/tools", VCS:"git", RepoRoot:"https://go.googlesource.com/tools"} at https://golang.org/x/tools/go/buildutil?go-get=1 get "golang.org/x/tools/go/buildutil": verifying non-authoritative meta tag Fetching https://golang.org/x/tools?go-get=1 Parsing meta tags from https://golang.org/x/tools?go-get=1 (status code 200) golang.org/x/tools (download) # cd C:Usersusergosrcgolang.orgxtools; git pull --ff-only fatal: Not a git repository (or any of the parent directories): .git package golang.org/x/tools/go/buildutil: exit status 128 guru: Error: Command failed: C:Gobingo.exe get -u -v golang.org/x/tools/cmd/guru Fetching https://golang.org/x/tools/cmd/guru?go-get=1 Parsing meta tags from https://golang.org/x/tools/cmd/guru?go-get=1 (status code 200) get "golang.org/x/tools/cmd/guru": found meta tag main.metaImport{Prefix:"golang.org/x/tools", VCS:"git", RepoRoot:"https://go.googlesource.com/tools"} at https://golang.org/x/tools/cmd/guru?go-get=1 get "golang.org/x/tools/cmd/guru": verifying non-authoritative meta tag Fetching https://golang.org/x/tools?go-get=1 Parsing meta tags from https://golang.org/x/tools?go-get=1 (status code 200) golang.org/x/tools (download) # cd C:Usersusergosrcgolang.orgxtools; git pull --ff-only fatal: Not a git repository (or any of the parent directories): .git package golang.org/x/tools/cmd/guru: exit status 128 Fetching https://golang.org/x/tools/cmd/guru?go-get=1 Parsing meta tags from https://golang.org/x/tools/cmd/guru?go-get=1 (status code 200) get "golang.org/x/tools/cmd/guru": found meta tag main.metaImport{Prefix:"golang.org/x/tools", VCS:"git", RepoRoot:"https://go.googlesource.com/tools"} at https://golang.org/x/tools/cmd/guru?go-get=1 get "golang.org/x/tools/cmd/guru": verifying non-authoritative meta tag Fetching https://golang.org/x/tools?go-get=1 Parsing meta tags from https://golang.org/x/tools?go-get=1 (status code 200) golang.org/x/tools (download) # cd C:Usersusergosrcgolang.orgxtools; git pull --ff-only fatal: Not a git repository (or any of the parent directories): .git package golang.org/x/tools/cmd/guru: exit status 128 gorename: Error: Command failed: C:Gobingo.exe get -u -v golang.org/x/tools/cmd/gorename Fetching https://golang.org/x/tools/cmd/gorename?go-get=1 Parsing meta tags from https://golang.org/x/tools/cmd/gorename?go-get=1 (status code 200) get "golang.org/x/tools/cmd/gorename": found meta tag main.metaImport{Prefix:"golang.org/x/tools", VCS:"git", RepoRoot:"https://go.googlesource.com/tools"} at https://golang.org/x/tools/cmd/gorename?go-get=1 get "golang.org/x/tools/cmd/gorename": verifying non-authoritative meta tag Fetching https://golang.org/x/tools?go-get=1 Parsing meta tags from https://golang.org/x/tools?go-get=1 (status code 200) golang.org/x/tools (download) # cd C:Usersusergosrcgolang.orgxtools; git pull --ff-only fatal: Not a git repository (or any of the parent directories): .git package golang.org/x/tools/cmd/gorename: exit status 128 Fetching https://golang.org/x/tools/cmd/gorename?go-get=1 Parsing meta tags from https://golang.org/x/tools/cmd/gorename?go-get=1 (status code 200) get "golang.org/x/tools/cmd/gorename": found meta tag main.metaImport{Prefix:"golang.org/x/tools", VCS:"git", RepoRoot:"https://go.googlesource.com/tools"} at https://golang.org/x/tools/cmd/gorename?go-get=1 get "golang.org/x/tools/cmd/gorename": verifying non-authoritative meta tag Fetching https://golang.org/x/tools?go-get=1 Parsing meta tags from https://golang.org/x/tools?go-get=1 (status code 200) golang.org/x/tools (download) # cd C:Usersusergosrcgolang.orgxtools; git pull --ff-only fatal: Not a git repository (or any of the parent directories): .git package golang.org/x/tools/cmd/gorename: exit status 128 goreturns: Error: Command failed: C:Gobingo.exe get -u -v sourcegraph.com/sqs/goreturns Fetching https://sourcegraph.com/sqs/goreturns?go-get=1 Parsing meta tags from https://sourcegraph.com/sqs/goreturns?go-get=1 (status code 200) get "sourcegraph.com/sqs/goreturns": found meta tag main.metaImport{Prefix:"sourcegraph.com/sqs/goreturns", VCS:"git", RepoRoot:"https://github.com/sqs/goreturns"} at https://sourcegraph.com/sqs/goreturns?go-get=1 sourcegraph.com/sqs/goreturns (download) github.com/sqs/goreturns (download) Fetching https://golang.org/x/tools/imports?go-get=1 Parsing meta tags from https://golang.org/x/tools/imports?go-get=1 (status code 200) get "golang.org/x/tools/imports": found meta tag main.metaImport{Prefix:"golang.org/x/tools", VCS:"git", RepoRoot:"https://go.googlesource.com/tools"} at https://golang.org/x/tools/imports?go-get=1 get "golang.org/x/tools/imports": verifying non-authoritative meta tag Fetching https://golang.org/x/tools?go-get=1 Parsing meta tags from https://golang.org/x/tools?go-get=1 (status code 200) golang.org/x/tools (download) # cd C:Usersusergosrcgolang.orgxtools; git pull --ff-only fatal: Not a git repository (or any of the parent directories): .git package golang.org/x/tools/imports: exit status 128 Fetching https://sourcegraph.com/sqs/goreturns?go-get=1 Parsing meta tags from https://sourcegraph.com/sqs/goreturns?go-get=1 (status code 200) get "sourcegraph.com/sqs/goreturns": found meta tag main.metaImport{Prefix:"sourcegraph.com/sqs/goreturns", VCS:"git", RepoRoot:"https://github.com/sqs/goreturns"} at https://sourcegraph.com/sqs/goreturns?go-get=1 sourcegraph.com/sqs/goreturns (download) github.com/sqs/goreturns (download) Fetching https://golang.org/x/tools/imports?go-get=1 Parsing meta tags from https://golang.org/x/tools/imports?go-get=1 (status code 200) get "golang.org/x/tools/imports": found meta tag main.metaImport{Prefix:"golang.org/x/tools", VCS:"git", RepoRoot:"https://go.googlesource.com/tools"} at https://golang.org/x/tools/imports?go-get=1 get "golang.org/x/tools/imports": verifying non-authoritative meta tag Fetching https://golang.org/x/tools?go-get=1 Parsing meta tags from https://golang.org/x/tools?go-get=1 (status code 200) golang.org/x/tools (download) # cd C:Usersusergosrcgolang.orgxtools; git pull --ff-only fatal: Not a git repository (or any of the parent directories): .git package golang.org/x/tools/imports: exit status 128 golint: Error: Command failed: C:Gobingo.exe get -u -v github.com/golang/lint/golint github.com/golang/lint (download) Fetching https://golang.org/x/tools/go/gcexportdata?go-get=1 Parsing meta tags from https://golang.org/x/tools/go/gcexportdata?go-get=1 (status code 200) get "golang.org/x/tools/go/gcexportdata": found meta tag main.metaImport{Prefix:"golang.org/x/tools", VCS:"git", RepoRoot:"https://go.googlesource.com/tools"} at https://golang.org/x/tools/go/gcexportdata?go-get=1 get "golang.org/x/tools/go/gcexportdata": verifying non-authoritative meta tag Fetching https://golang.org/x/tools?go-get=1 Parsing meta tags from https://golang.org/x/tools?go-get=1 (status code 200) golang.org/x/tools (download) # cd C:Usersusergosrcgolang.orgxtools; git pull --ff-only fatal: Not a git repository (or any of the parent directories): .git package golang.org/x/tools/go/gcexportdata: exit status 128 github.com/golang/lint (download) Fetching https://golang.org/x/tools/go/gcexportdata?go-get=1 Parsing meta tags from https://golang.org/x/tools/go/gcexportdata?go-get=1 (status code 200) get "golang.org/x/tools/go/gcexportdata": found meta tag main.metaImport{Prefix:"golang.org/x/tools", VCS:"git", RepoRoot:"https://go.googlesource.com/tools"} at https://golang.org/x/tools/go/gcexportdata?go-get=1 get "golang.org/x/tools/go/gcexportdata": verifying non-authoritative meta tag Fetching https://golang.org/x/tools?go-get=1 Parsing meta tags from https://golang.org/x/tools?go-get=1 (status code 200) golang.org/x/tools (download) # cd C:Usersusergosrcgolang.orgxtools; git pull --ff-only fatal: Not a git repository (or any of the parent directories): .git package golang.org/x/tools/go/gcexportdata: exit status 128 gotests: Error: Command failed: C:Gobingo.exe get -u -v github.com/cweill/gotests/... github.com/cweill/gotests (download) Fetching https://golang.org/x/tools/imports?go-get=1 Parsing meta tags from https://golang.org/x/tools/imports?go-get=1 (status code 200) get "golang.org/x/tools/imports": found meta tag main.metaImport{Prefix:"golang.org/x/tools", VCS:"git", RepoRoot:"https://go.googlesource.com/tools"} at https://golang.org/x/tools/imports?go-get=1 get "golang.org/x/tools/imports": verifying non-authoritative meta tag Fetching https://golang.org/x/tools?go-get=1 Parsing meta tags from https://golang.org/x/tools?go-get=1 (status code 200) golang.org/x/tools (download) # cd C:Usersusergosrcgolang.orgxtools; git pull --ff-only fatal: Not a git repository (or any of the parent directories): .git package golang.org/x/tools/imports: exit status 128 github.com/cweill/gotests (download) Fetching https://golang.org/x/tools/imports?go-get=1 Parsing meta tags from https://golang.org/x/tools/imports?go-get=1 (status code 200) get "golang.org/x/tools/imports": found meta tag main.metaImport{Prefix:"golang.org/x/tools", VCS:"git", RepoRoot:"https://go.googlesource.com/tools"} at https://golang.org/x/tools/imports?go-get=1 get "golang.org/x/tools/imports": verifying non-authoritative meta tag Fetching https://golang.org/x/tools?go-get=1 Parsing meta tags from https://golang.org/x/tools?go-get=1 (status code 200) golang.org/x/tools (download) # cd C:Usersusergosrcgolang.orgxtools; git pull --ff-only fatal: Not a git repository (or any of the parent directories): .git package golang.org/x/tools/imports: exit status 128
有些工具可以安装,有些则不能。我对这个错误无能为力,Not a git repository
因为它是一个自动化过程,而且我不是输入 git 命令的人。
我尝试在 PowerShell 中单独安装这些工具,但我得到了同样的错误。我的 go 目录已创建(在
中%USERPROFILE%go
)并且GOPATH
设置正确。
有任何想法吗 ?
正确答案
看起来它因为C:Usersusergosrcgolang.orgxtools
不是 git repo
而在抱怨,所以它无法更新其中的任何内容。
假设您没有将自己的代码放在该目录中,请尝试将其删除然后再次运行。
如果您查看 Go 插件的文档,并一直滚动到底部,如果您想手动安装/升级插件所需的东西,它会显示要运行的命令。
具体来说,取自[他们的 github repo](https://github.com/Microsoft/vscode-go#tools-this- extension-depends-on),您可以从 cmd.exe 提示符下运行它。
go get -u -v github.com/nsf/gocode go get -u -v github.com/rogpeppe/godef go get -u -v github.com/zmb3/gogetdoc go get -u -v github.com/golang/lint/golint 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 go get -u -v golang.org/x/tools/cmd/guru go get -u -v github.com/cweill/gotests/... go get -u -v golang.org/x/tools/cmd/godoc go get -u -v github.com/fatih/gomodifytags
今天关于《VSCode无法安装Go工具怎么解决》的内容就介绍到这里了,是不是学起来一目了然!想要了解更多关于golang的内容请关注golang学习网公众号!
-
439 收藏
-
262 收藏
-
193 收藏
-
188 收藏
-
500 收藏
-
139 收藏
-
204 收藏
-
325 收藏
-
477 收藏
-
486 收藏
-
439 收藏
-
- 前端进阶之JavaScript设计模式
- 设计模式是开发人员在软件开发过程中面临一般问题时的解决方案,代表了最佳的实践。本课程的主打内容包括JS常见设计模式以及具体应用场景,打造一站式知识长龙服务,适合有JS基础的同学学习。
- 立即学习 542次学习
-
- GO语言核心编程课程
- 本课程采用真实案例,全面具体可落地,从理论到实践,一步一步将GO核心编程技术、编程思想、底层实现融会贯通,使学习者贴近时代脉搏,做IT互联网时代的弄潮儿。
- 立即学习 507次学习
-
- 简单聊聊mysql8与网络通信
- 如有问题加微信:Le-studyg;在课程中,我们将首先介绍MySQL8的新特性,包括性能优化、安全增强、新数据类型等,帮助学生快速熟悉MySQL8的最新功能。接着,我们将深入解析MySQL的网络通信机制,包括协议、连接管理、数据传输等,让
- 立即学习 497次学习
-
- JavaScript正则表达式基础与实战
- 在任何一门编程语言中,正则表达式,都是一项重要的知识,它提供了高效的字符串匹配与捕获机制,可以极大的简化程序设计。
- 立即学习 487次学习
-
- 从零制作响应式网站—Grid布局
- 本系列教程将展示从零制作一个假想的网络科技公司官网,分为导航,轮播,关于我们,成功案例,服务流程,团队介绍,数据部分,公司动态,底部信息等内容区块。网站整体采用CSSGrid布局,支持响应式,有流畅过渡和展现动画。
- 立即学习 484次学习