为什么GoDoc不显示接口变量?

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

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,而AlphaBeta当然会在输出中显示。这种行为似乎可以在任何声明为接口类型的导出变量中复现。

为什么会这样呢?

英文:

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

huangapple
  • 本文由 发表于 2013年11月24日 03:14:21
  • 转载请务必保留本文链接:https://go.coder-hub.com/20166658.html
匿名

发表评论

匿名网友

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

确定