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