Interfaces Example in Go

If it walks like a duck and it quacks like a duck, then it must be a duck

Jerry An

--

What’s an interface?

The interface is a custom type used to specify a set of one or more method signatures.

For example:

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

The Reader is an interface that defines a method signature for reading data. This method takes a byte slice and returns the number of bytes read.

--

--