io.Writer

The Go interface for anything you can write bytes to, such as a file, standard output, a buffer or an HTTP response.

In more detail

Its one method, Write, takes a byte slice. fmt.Fprintf, io.Copy and json.NewEncoder all write to any io.Writer, so the same code can print to a terminal or fill a buffer in a test.

Example

var target bytes.Buffer

Related terms

Taught in

References