I/O Stream Abstractions
advanced
I/O stream abstractions like Go's io.Reader and io.Writer model data as a flow of bytes behind a tiny interface, so files, sockets, buffers and encoders compose interchangeably without each one knowing the others' concrete type.
I/O stream abstractions reduce reading and writing to a minimal byte-oriented contract: a Reader fills a buffer and reports how many bytes and any error, while a Writer consumes a buffer. Because the interface is tiny, any source or sink such as a file, network connection, in-memory buffer, or compressor can implement it, and they compose by wrapping.
Read the original → https://go.dev/tour/methods/20
- #go
- #io
- #streams
- #reader-writer
- #composition
Get five bites like this every day.
Tezvyn delivers a daily feed of 60-second tech bites with quizzes to lock in what you learn.