2
package main
type Writeable interface {
OnWrite() interface{}
}
type Result struct {
Message string
}
func (r *Result) OnWrite() interface{} {
return r.Message
}
// what does this line mean? what is the purpose?
var _ Writeable = (*Result)(nil)
func main() {
}
代码片段中的注释表达了我的困惑。 据我所知,带注释的行通知编译器检查结构是否实现了接口,但我不太确定。有人可以帮助解释目的吗?无法理解一段golang代码
[这是什么变量声明与下划线,内联接口和赋值?](http://stackoverflow.com/questions/14202181/what-is-this-variable-declaration-with-underscore-inline-接口和 - assignme) – Volker