io.Copy transfers data from any io.Reader to any io.Writer until the input reaches end of file or an error occurs. It provides a general stream-copying operation without tying the implementation to files or another specific source and destination. section 10.3
The function fits Go’s composable I/O design: callers can connect different sources and sinks through the small io.Reader and io.Writer interfaces. Use io.CopyN instead when the operation must stop after a specific byte count. section 10.3
Files and streaming data
Use io.Copy for copying files or streaming data between sources and sinks, while choosing io.CopyN for copying only part of a stream. section 10.3
Figure 10.1 io.Reader and io.Writer interface composition with multiple package implementations
The interface-composition figure helps map io.Copy’s generic operation across multiple Reader and Writer implementations. section 10.3

