3 ms·
Yes, easily: var rc io.ReadCloser // a file, whatever readerOnly := struct{io.Reader}{rc} // only a Reader
by enneff 13y ago
Yes, easily:
var rc io.ReadCloser // a file, whatever
readerOnly := struct{io.Reader}{rc} // only a Reader
- frou_dh 13y agoThat's cool. The io.Reader is an unnamed field, so its method is effectively pushed to the surface of the wrapping struct instead of needing to be explicitly forwarded to.