01-reading-a-file-in-chuncks-of-a-bytes

command
v0.0.0-...-9882766 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 26, 2022 License: Apache-2.0 Imports: 2 Imported by: 0

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.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL