Use io.Copy for full transfers, io.CopyN for fixed sizes, and io.CopyBuffer for high-performance streaming with a reusable buffer.
Use io.Copy to transfer all data, io.CopyN to transfer a fixed byte count, and io.CopyBuffer to reuse a buffer for performance.
// Copy all data from src to dst
n, err := io.Copy(dst, src)
// Copy exactly 1024 bytes
n, err := io.CopyN(dst, src, 1024)
// Copy all data using a reusable 32KB buffer
buf := make([]byte, 32<<10)
n, err := io.CopyBuffer(dst, src, buf)
These functions move data from a source to a destination. Use the standard copy for simple tasks, the limited copy when you only need a specific amount of data, and the buffered copy to speed up large transfers by reusing memory instead of creating new buffers constantly.