Error loading workspace: err: exit status 1: stderr: go: updates to go.sum needed, disabled by -mod=readonly : packages.Load error

huangapple go评论145阅读模式
英文:

Error loading workspace: err: exit status 1: stderr: go: updates to go.sum needed, disabled by -mod=readonly : packages.Load error

问题

我正在使用VSCode和vscode-go来开发Go应用程序,但有时候我会遇到这个错误,无法跳转到代码定义处。

我该如何解决这个错误并恢复所有gopls功能?

英文:

I am using VSCode and vscode-go to develop the Go application,but, sometime, I got this error, and can't jump to the code definination

How can I get past this error message and get back all gopls features?

答案1

得分: 7

根据golang/vscode-go问题1229的解释:

> 错误消息表明go.mod文件不完整,需要更新。
>
> 检查“PROBLEMS”视图(<kbd>Ctrl</kbd>+<kbd>Shift</kbd>+<kbd>P</kbd> &gt; “Problems: Focus On Problems View”),找到错误级别的问题(可能在go.mod文件中),然后选择快速修复或检查灯泡。
>
> 或者,简单地打开go.mod文件并在文件顶部使用代码镜头运行'go mod tidy'。

Error loading workspace: err: exit status 1: stderr: go: updates to go.sum needed, disabled by -mod=readonly : packages.Load error

显然,请确保您使用的是最新版本(Go、VSCode和vscode-go,以及gopls)

英文:

As explained in golang/vscode-go issue 1229:

> The error message indicates the go.mod file is incomplete and needs update.
>
> Check the "PROBLEMS" view (<kbd>Ctrl</kbd>+<kbd>Shift</kbd>+<kbd>P</kbd> &gt; &quot;Problems: Focus On Problems View" ), find the error-level problem (probably in the go.mod file), and either choose the Quick Fix or check the light bulb.
>
> Or, simply open the go.mod file and run 'go mod tidy' using the code lens at the top of the file.

Error loading workspace: err: exit status 1: stderr: go: updates to go.sum needed, disabled by -mod=readonly : packages.Load error

Obviously, make sure you are using the latest versions (of Go, VSCode and vscode-go, as well as gopls)

huangapple
  • 本文由 发表于 2021年6月2日 15:23:49
  • 转载请务必保留本文链接:https://go.coder-hub.com/67800641.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定