Quick way to combine io.Reader and io.Closer
There are many interesting tools in Golang’s standard library to wrap io.Reader instance such as io.LimitedReader or cipher.StreamReader. But when wrapping a io.ReadCloser instance, the Close method is hidden. Here’s a quick code snippet to combine wrapped io.Reader and the original io.Closer through an inline struct to rebuild the io.Closer interface. Code var rc io.ReadCloser = struct { io.Reader io.Closer }{ Reader: r, Closer: c, } What it is about? The io....