0PricingLogin
Go Academy · Lesson

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

  1. The Reader Interface
  2. The Writer Interface
  3. io Utility Functions
  4. Implementing Custom Readers
← Back to Go Academy