Documentation ¶
Overview ¶
io.Reader is an interface of type Reader, that is defined within the io package. The Reader interface only has one description of a method defined, and that is:
type Reader interface { read(p []byte) (n int, err error) }
This means that any other type that has a "read(p []byte) (n int, err error)" method satisfies the Reader interface. When a type satisfy an interface it will also become the type interface it satisfies. That means if we have "type badger string",
with a read method, the 'badger' type will also become a type 'Reader'.
This lets us use the 'badger' type as input or output anywhere an io.Reader is wanted. We can also create a new variable of type 'Reader' and fill that with a type 'badger' value.
Click to show internal directories.
Click to hide internal directories.