Listing Interfaces in Go Interfaces

I do not understand the following code fragment in the container/heap package.

 type Interface interface { sort.Interface //Is this line a method? Push(x interface{}) Pop() interface{} } 
+7
source share
1 answer

This is a type declaration.

The heap.Interface interface includes the sort.Interface interface.

You can see this as a form of inheritance / specialization: this means that structures that implement the heap.Interface interface heap.Interface defined as those that implement the sort.Interface methods and the Push and Pop methods.

Embedding the interface is described in Effective Go: http://golang.org/doc/effective_go.html#embedding

+7
source

All Articles