go - 尝试安装依赖项时 VS Code 总是失败

标签 go visual-studio-code

我尝试使用此处的示例 https://github.com/dejavuzhou/felix

我已经成功地从那里创建了我的项目。我的项目运行良好。只是我用VSCode打开项目时,总是发现下载依赖的通知

enter image description here

但是当我按下 Install All 时,所有依赖项的下载总是失败。

来自 VSCode 的错误报告

Installing 8 tools at C:\Users\berth\go\bin
  gocode
  go-outline
  go-symbols
  guru
  gorename
  gocode-gomod
  goreturns
  golint

C:\Users\berth\go\src\github.com\berthojoris\ginbro\handlers>Finished running tool: C:\Go\bin\go.exe build -i -o C:\Users\berth\AppData\Local\Temp\vscode-go8ZWFLb\go-code-check github.com\berthojoris\ginbro\handlers

C:\Users\berth\go\src\github.com\berthojoris\ginbro\handlers>Finished running tool: C:\Go\bin\go.exe vet ./...

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.

gocode:
Error: Command failed: C:\Go\bin\go.exe get -u -v github.com/mdempsky/gocode
github.com/mdempsky/gocode (download)
# cd C:\Users\berth\go\src\github.com\mdempsky\gocode; git pull --ff-only
There is no tracking information for the current branch.
Please specify which branch you want to merge with.
See git-pull(1) for details.

    git pull <remote> <branch>

If you wish to set tracking information for this branch you can do so with:

    git branch --set-upstream-to=origin/<branch> master

package github.com/mdempsky/gocode: exit status 1
github.com/mdempsky/gocode (download)
# cd C:\Users\berth\go\src\github.com\mdempsky\gocode; git pull --ff-only
There is no tracking information for the current branch.
Please specify which branch you want to merge with.
See git-pull(1) for details.

    git pull <remote> <branch>

If you wish to set tracking information for this branch you can do so with:

    git branch --set-upstream-to=origin/<branch> master

package github.com/mdempsky/gocode: exit status 1

go-outline:
Error: Command failed: C:\Go\bin\go.exe get -u -v github.com/ramya-rao-a/go-outline
github.com/ramya-rao-a/go-outline (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 get.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:\Users\berth\go\src\golang.org\x\tools; git pull --ff-only
There is no tracking information for the current branch.
Please specify which branch you want to merge with.
See git-pull(1) for details.

    git pull <remote> <branch>

If you wish to set tracking information for this branch you can do so with:

    git branch --set-upstream-to=origin/<branch> master

package golang.org/x/tools/go/buildutil: exit status 1
github.com/ramya-rao-a/go-outline (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 get.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:\Users\berth\go\src\golang.org\x\tools; git pull --ff-only
There is no tracking information for the current branch.
Please specify which branch you want to merge with.
See git-pull(1) for details.

    git pull <remote> <branch>

If you wish to set tracking information for this branch you can do so with:

    git branch --set-upstream-to=origin/<branch> master

package golang.org/x/tools/go/buildutil: exit status 1

go-symbols:
Error: Command failed: C:\Go\bin\go.exe get -u -v github.com/acroca/go-symbols
github.com/acroca/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 get.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:\Users\berth\go\src\golang.org\x\tools; git pull --ff-only
There is no tracking information for the current branch.
Please specify which branch you want to merge with.
See git-pull(1) for details.

    git pull <remote> <branch>

If you wish to set tracking information for this branch you can do so with:

    git branch --set-upstream-to=origin/<branch> master

package golang.org/x/tools/go/buildutil: exit status 1
github.com/acroca/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 get.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:\Users\berth\go\src\golang.org\x\tools; git pull --ff-only
There is no tracking information for the current branch.
Please specify which branch you want to merge with.
See git-pull(1) for details.

    git pull <remote> <branch>

If you wish to set tracking information for this branch you can do so with:

    git branch --set-upstream-to=origin/<branch> master

package golang.org/x/tools/go/buildutil: exit status 1

guru:
Error: Command failed: C:\Go\bin\go.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 get.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:\Users\berth\go\src\golang.org\x\tools; git pull --ff-only
There is no tracking information for the current branch.
Please specify which branch you want to merge with.
See git-pull(1) for details.

    git pull <remote> <branch>

If you wish to set tracking information for this branch you can do so with:

    git branch --set-upstream-to=origin/<branch> master

package golang.org/x/tools/cmd/guru: exit status 1
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 get.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:\Users\berth\go\src\golang.org\x\tools; git pull --ff-only
There is no tracking information for the current branch.
Please specify which branch you want to merge with.
See git-pull(1) for details.

    git pull <remote> <branch>

If you wish to set tracking information for this branch you can do so with:

    git branch --set-upstream-to=origin/<branch> master

package golang.org/x/tools/cmd/guru: exit status 1

gorename:
Error: Command failed: C:\Go\bin\go.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 get.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:\Users\berth\go\src\golang.org\x\tools; git pull --ff-only
There is no tracking information for the current branch.
Please specify which branch you want to merge with.
See git-pull(1) for details.

    git pull <remote> <branch>

If you wish to set tracking information for this branch you can do so with:

    git branch --set-upstream-to=origin/<branch> master

package golang.org/x/tools/cmd/gorename: exit status 1
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 get.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:\Users\berth\go\src\golang.org\x\tools; git pull --ff-only
There is no tracking information for the current branch.
Please specify which branch you want to merge with.
See git-pull(1) for details.

    git pull <remote> <branch>

If you wish to set tracking information for this branch you can do so with:

    git branch --set-upstream-to=origin/<branch> master

package golang.org/x/tools/cmd/gorename: exit status 1

gocode-gomod:
Error: Command failed: C:\Go\bin\go.exe get -u -v -d github.com/stamblerre/gocode
github.com/stamblerre/gocode (download)
Fetching https://golang.org/x/tools/go/packages?go-get=1
Parsing meta tags from https://golang.org/x/tools/go/packages?go-get=1 (status code 200)
get "golang.org/x/tools/go/packages": found meta tag get.metaImport{Prefix:"golang.org/x/tools", VCS:"git", RepoRoot:"https://go.googlesource.com/tools"} at https://golang.org/x/tools/go/packages?go-get=1
get "golang.org/x/tools/go/packages": 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:\Users\berth\go\src\golang.org\x\tools; git pull --ff-only
There is no tracking information for the current branch.
Please specify which branch you want to merge with.
See git-pull(1) for details.

    git pull <remote> <branch>

If you wish to set tracking information for this branch you can do so with:

    git branch --set-upstream-to=origin/<branch> master

package golang.org/x/tools/go/packages: exit status 1
github.com/stamblerre/gocode (download)
Fetching https://golang.org/x/tools/go/packages?go-get=1
Parsing meta tags from https://golang.org/x/tools/go/packages?go-get=1 (status code 200)
get "golang.org/x/tools/go/packages": found meta tag get.metaImport{Prefix:"golang.org/x/tools", VCS:"git", RepoRoot:"https://go.googlesource.com/tools"} at https://golang.org/x/tools/go/packages?go-get=1
get "golang.org/x/tools/go/packages": 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:\Users\berth\go\src\golang.org\x\tools; git pull --ff-only
There is no tracking information for the current branch.
Please specify which branch you want to merge with.
See git-pull(1) for details.

    git pull <remote> <branch>

If you wish to set tracking information for this branch you can do so with:

    git branch --set-upstream-to=origin/<branch> master

package golang.org/x/tools/go/packages: exit status 1

goreturns:
Error: Command failed: C:\Go\bin\go.exe get -u -v github.com/sqs/goreturns
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 get.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:\Users\berth\go\src\golang.org\x\tools; git pull --ff-only
There is no tracking information for the current branch.
Please specify which branch you want to merge with.
See git-pull(1) for details.

    git pull <remote> <branch>

If you wish to set tracking information for this branch you can do so with:

    git branch --set-upstream-to=origin/<branch> master

package golang.org/x/tools/imports: exit status 1
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 get.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:\Users\berth\go\src\golang.org\x\tools; git pull --ff-only
There is no tracking information for the current branch.
Please specify which branch you want to merge with.
See git-pull(1) for details.

    git pull <remote> <branch>

If you wish to set tracking information for this branch you can do so with:

    git branch --set-upstream-to=origin/<branch> master

package golang.org/x/tools/imports: exit status 1

golint:
Error: Command failed: C:\Go\bin\go.exe get -u -v golang.org/x/lint/golint
Fetching https://golang.org/x/lint/golint?go-get=1
Parsing meta tags from https://golang.org/x/lint/golint?go-get=1 (status code 200)
get "golang.org/x/lint/golint": found meta tag get.metaImport{Prefix:"golang.org/x/lint", VCS:"git", RepoRoot:"https://go.googlesource.com/lint"} at https://golang.org/x/lint/golint?go-get=1
get "golang.org/x/lint/golint": verifying non-authoritative meta tag
Fetching https://golang.org/x/lint?go-get=1
Parsing meta tags from https://golang.org/x/lint?go-get=1 (status code 200)
golang.org/x/lint (download)
Fetching https://golang.org/x/lint?go-get=1
Parsing meta tags from https://golang.org/x/lint?go-get=1 (status code 200)
get "golang.org/x/lint": found meta tag get.metaImport{Prefix:"golang.org/x/lint", VCS:"git", RepoRoot:"https://go.googlesource.com/lint"} at https://golang.org/x/lint?go-get=1
Fetching https://golang.org/x/tools/go/ast/astutil?go-get=1
Parsing meta tags from https://golang.org/x/tools/go/ast/astutil?go-get=1 (status code 200)
get "golang.org/x/tools/go/ast/astutil": found meta tag get.metaImport{Prefix:"golang.org/x/tools", VCS:"git", RepoRoot:"https://go.googlesource.com/tools"} at https://golang.org/x/tools/go/ast/astutil?go-get=1
get "golang.org/x/tools/go/ast/astutil": 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:\Users\berth\go\src\golang.org\x\tools; git pull --ff-only
There is no tracking information for the current branch.
Please specify which branch you want to merge with.
See git-pull(1) for details.

    git pull <remote> <branch>

If you wish to set tracking information for this branch you can do so with:

    git branch --set-upstream-to=origin/<branch> master

package golang.org/x/tools/go/ast/astutil: exit status 1
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 get.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
package golang.org/x/tools/go/gcexportdata: cannot find package "golang.org/x/tools/go/gcexportdata" in any of:
    c:\go\src\golang.org\x\tools\go\gcexportdata (from $GOROOT)
    C:\Users\berth\go\src\golang.org\x\tools\go\gcexportdata (from $GOPATH)
Fetching https://golang.org/x/lint/golint?go-get=1
Parsing meta tags from https://golang.org/x/lint/golint?go-get=1 (status code 200)
get "golang.org/x/lint/golint": found meta tag get.metaImport{Prefix:"golang.org/x/lint", VCS:"git", RepoRoot:"https://go.googlesource.com/lint"} at https://golang.org/x/lint/golint?go-get=1
get "golang.org/x/lint/golint": verifying non-authoritative meta tag
Fetching https://golang.org/x/lint?go-get=1
Parsing meta tags from https://golang.org/x/lint?go-get=1 (status code 200)
golang.org/x/lint (download)
Fetching https://golang.org/x/lint?go-get=1
Parsing meta tags from https://golang.org/x/lint?go-get=1 (status code 200)
get "golang.org/x/lint": found meta tag get.metaImport{Prefix:"golang.org/x/lint", VCS:"git", RepoRoot:"https://go.googlesource.com/lint"} at https://golang.org/x/lint?go-get=1
Fetching https://golang.org/x/tools/go/ast/astutil?go-get=1
Parsing meta tags from https://golang.org/x/tools/go/ast/astutil?go-get=1 (status code 200)
get "golang.org/x/tools/go/ast/astutil": found meta tag get.metaImport{Prefix:"golang.org/x/tools", VCS:"git", RepoRoot:"https://go.googlesource.com/tools"} at https://golang.org/x/tools/go/ast/astutil?go-get=1
get "golang.org/x/tools/go/ast/astutil": 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:\Users\berth\go\src\golang.org\x\tools; git pull --ff-only
There is no tracking information for the current branch.
Please specify which branch you want to merge with.
See git-pull(1) for details.

    git pull <remote> <branch>

If you wish to set tracking information for this branch you can do so with:

    git branch --set-upstream-to=origin/<branch> master

package golang.org/x/tools/go/ast/astutil: exit status 1
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 get.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
package golang.org/x/tools/go/gcexportdata: cannot find package "golang.org/x/tools/go/gcexportdata" in any of:
    c:\go\src\golang.org\x\tools\go\gcexportdata (from $GOROOT)
    C:\Users\berth\go\src\golang.org\x\tools\go\gcexportdata (from $GOPATH)

由于我是 Golang 的新手,我该如何解决这个问题。

或者我应该忽略来自 VSCode 的警告?

谢谢

最佳答案

dejavuzhou/felix有一个 go.momd 和 go.sum:它取决于 go modules

因此请确保您的 VScode 使用 Go 1.11+ 和

  • 没有 GOPATH
  • GO111MODULE 设置

(参见 troubleshooting)

如评论:

  • set GO111MODULE to the value on in your Windows System environment variable.
  • Then launch VSCode, and set in your JSon Users settings go.toolsGopath to a new empty folder, dedicated for tools.
  • Then try and build your project in VSCode, to see if your initial error message still persists.

关于go - 尝试安装依赖项时 VS Code 总是失败,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/56911553/

相关文章:

go - 如何使用 Channels 使 goroutines 相互通信

visual-studio-code - VS Code 中的功能名称是什么,您可以将鼠标悬停在变量上并查看它的定义位置?

autocomplete - 标准库中的项目未显示 Rust 自动完成

go - 如何在 Golang 中快速找到接口(interface)的实现?

go - 如何使用 go mod vendor 从 GOPATH 复制 deps?

go - 净/http : TLS handshake timeout when call external https from google cloud

go - 该程序在后台监听连接并等待用户输入

macos - 当我在具有多个显示器的 macOS 中切换桌面时,为什么焦点会切换到另一个意外的应用程序(在我的情况下是 iTerm2 或 VSCode)?

node.js - VS Code Nodejs远程调试: breakpoints are getting ignored

visual-studio-code - VS 代码 : How to exclude folders from npm task auto-detection?