英文:
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> > “Problems: Focus On Problems View”),找到错误级别的问题(可能在go.mod文件中),然后选择快速修复或检查灯泡。
>
> 或者,简单地打开go.mod文件并在文件顶部使用代码镜头运行'go mod tidy'。
显然,请确保您使用的是最新版本(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> > "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.
Obviously, make sure you are using the latest versions (of Go, VSCode and vscode-go, as well as gopls)
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。



评论