io.Copy

The Go function that streams all the bytes from an io.Reader to an io.Writer and returns how many it copied.

In more detail

It moves data in small chunks, so memory use stays flat however large the stream is. Use it to save a download to a file or pass a body straight through.

Example

n, err := io.Copy(&target, source)

Related terms

Taught in

References