Listing interfaces in interfaces
Take a look at the following example of an interface definition, this one isfrom the package container/heap
:
type Interface interface {
sort.Interface
Push(x interface{})
Pop() interface{}
}
Here another interface is listed inside the definition of heap.Interface
, thismay look odd, but is perfectly valid, remember that on the surface an interface is nothingmore than a listing of methods. sort.Interface
is also such a listing, so it isperfectly legal to include it in the interface.
当前内容版权归 Miek Gieben 或其关联方所有,如需对内容或内容相关联开源项目进行关注与资助,请访问 Miek Gieben .