英文:
Why does GoDoc not show interface variables?
问题
考虑以下代码片段:
package example
type Foo interface {
}
var Alpha = "alpha"
var Beta string = "beta"
var Gamma Foo = "gamma"
无论是godoc
(-http=:6060
)还是go doc
,都完全忽略了Gamma
,而Alpha
和Beta
当然会在输出中显示。这种行为似乎可以在任何声明为接口类型的导出变量中复现。
为什么会这样呢?
英文:
Considering the following snippet:
package example
type Foo interface {
}
var Alpha = "alpha"
var Beta string = "beta"
var Gamma Foo = "gamma"
Both godoc
(-http=:6060
) and go doc
ignore Gamma
entirely, whilst Alpha
and Beta
are - of course - shown in the output. This behavior seems to be reproducible with any exported variable that is declared to be an interface type.
Why?
答案1
得分: 1
在我的系统上没有确认。我可以看到所有内容,包括Gamma。
变量Gamma在类型Foo定义之后。
但是在我的系统上安装了一个golang的开发版本:
go version devel +1140207a3395 Wed Nov 20 13:47:37 2013 -0800 linux/amd64
英文:
Unconfirmed at my system. I see all, including Gamma.
Var Gamma is placed after type Foo definition.
But at my system a devel version of golang is installed:
go version devel +1140207a3395 Wed Nov 20 13:47:37 2013 -0800 linux/amd64
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论