首页 > 解决方案 > gorename failing in VS Code without explicit error

问题描述

In VSCode, I am trying to rename a variable using F2. This seems to run the gorename tool, but fails every time without explicit error. It simply displays:

/home/oops/dev/mtg-tracker/mtg-tracker-server/handlers>Finished running tool: /home/oops/dev/go/bin/golint

/home/oops/dev/mtg-tracker/mtg-tracker-server/handlers>Finished running tool: /usr/local/go/bin/go build -i -o /tmp/vscode-goVw9yJs/go-code-check .

/home/oops/dev/mtg-tracker/mtg-tracker-server/handlers>Finished running tool: /usr/local/go/bin/go vet ./...

Rename failed

I've looked into similar issues and it seems to normally come with an error such as an invalid GOROOT or incorrect package naming, but I see no such error here and I haven't been able to find any further info.

I also saw that someone fixed this by updating gorename, which I tried looking into but have not been able to figure out how to do.

Expected result: VSCode actually renames my variable.

Actual result: The rename fails and it stays the same.

标签: govisual-studio-code

解决方案


请注意,有一个issue 24661专门用于跟踪工具及其更新,用于命令行或 VSCode 使用。

该问题仅包括

gorename将不再支持,因为gopls已经实现了重命名功能。

请参阅issue 27571,它指的是issue 32875

同时,等待对 的完全支持gorename,我正在使用saibing/tools它确实产生了一个“扩展”版本gopls,具有重命名支持。
这在 VSCode 中运行良好。


2019 年第四季度(11 月)更新:问题 32875现已关闭,gopls 已发布 0.2.0,应该修复这些错误。

完整的重命名支持仍然存在:CL 194878

保留 CL 207579:此更改添加了对prepare_rename.


2020 年 9 月更新:

正如CL 255053 (for go bundle) 中所评论的,此列表中的许多工具也已被替换gopls


推荐阅读