Interfaces

suggest change

An interface defines a set of methods on a struct.

Zero value of interface is nil.

Here’s the definition of the io.Reader interface from the standard library:

type Reader interface {
    Read(p []byte) (n int, err error)
}

The smaller the interface, the better.

Learn more about interfaces.

Feedback about page:

Feedback:
Optional: your email if you want me to get back to you:



Table Of Contents