The Writer Interface
Write to anything.
Write to Anything
io.Writer unifies all output: files, network, buffers, stdout, HTTP responses. One interface, many destinations.
The Interface Definition
The contract:
Write(p []byte) (n int, err error)
It writes p and returns how many bytes were written plus any error.
All lessons in this course
- The Reader Interface
- The Writer Interface
- io Utility Functions
- Implementing Custom Readers