October 2016
Beginner
348 pages
6h 31m
English
The io.Writer interface, as shown in the following code, is just as simple as its reader counterpart:
type Writer interface {
Write(p []byte) (n int, err error)
}
The interface requires the implementation of a single method, Write(p []byte)(c int, e error), that copies data from the provided stream p and writes that data to a sink resource such as an in-memory structure, standard output, a file, a network connection, or any number of io.Writer implementations that come with the Go standard library. The Write method returns the number of bytes copied from p followed by an error value if any was encountered.
The following code snippet shows the implementation of the channelWriter type, a writer that decomposes and serializes ...
Read now
Unlock full access