英文:
Does Go have a feature to automatically export unexported names?
问题
我正在遇到大量的错误,例如:
> foo.thing未定义(类型Foo没有字段或方法thing,但确实有Thing)
即修复非常简单,只需将foo.thing
更改为foo.Thing
。
在Go中,有没有一种方法可以告诉go build
批量进行这些更改?
英文:
I'm getting hundreds of errors like:
> foo.thing undefined (type Foo has no field or method thing, but does have Thing)
i.e. the fix is very simple, just change foo.thing
to foo.Thing
.
Is there a way in Go to tell go build
to just go ahead and make these changes in mass?
答案1
得分: 1
GoLand重构"重命名代码元素"可能是一个不错的方法。
VSCode的重命名符号也可以帮助。
但是Go本身没有这个功能。
有一个积压的功能请求,要求编译错误消息更加准确(问题38965)
不是(在这个例子中)
./prog.go:11:7: a.B undefined (type A has no field or method B, but does have b)
./prog.go:12:3: a.s undefined (type A has no field or method s, but does have S)
而是更具指导性的:
./prog.go:11:7: a.B undefined (type A has no field or method B, but does have field b)
./prog.go:12:3: a.s undefined (type A has no field or method s, but does have method S)
CL 232938,2020年5月,仍在等待中。
英文:
The GoLand refactoring "Rename a code element" might be a good approach.
VSCode rename symbol could help too.
But Go itself does not have that.
There is a backlog feature request for the compilation error message to be more precise (issue 38965)
Instead of (in this example)
./prog.go:11:7: a.B undefined (type A has no field or method B, but does have b)
./prog.go:12:3: a.s undefined (type A has no field or method s, but does have S)
Having the more prescriptive:
./prog.go:11:7: a.B undefined (type A has no field or method B, but does have field b)
./prog.go:12:3: a.s undefined (type A has no field or method s, but does have method S)
CL 232938, May 2020, still pending.
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论