Thanks for the suggestion of a ReadSeeker to wrap an io.Reader.

My google fu must be deserting me. I can find PushbackReader implementations in 
Java, but the only similar thing for Go I could find was 
https://gitlab.com/osaki-lab/iowrapper. If you have a specific recommendation 
for a ReadSeeker wrapper to an io.Reader that would be great to know.

Since the base64 decoding error I'm looking for is an EOF, I guess the wrapper 
approach will not work when the EOF byte position is > than the io.ReadSeeker 
buffer size.

Rory

On 12/01/25, robert engels (reng...@ix.netcom.com) wrote:
> create a ReadSeeker that wraps the Reader providing the buffering (mark & 
> reset) - normally the buffer only needs to be large enough to detect the 
> format contained in the Reader.
> 
> You can search Google for PushbackReader in Go and you’ll get a basic 
> implementation.
> 
> > On Jan 12, 2025, at 12:52 PM, Rory Campbell-Lange <r...@campbell-lange.net> 
> > wrote:
...
> > I'm attempting to rationalise the process [of avoiding reading email parts 
> > into byte slices] by simply wrapping the provided io.Reader with the 
> > necessary decoders to reduce memory usage and unnecessary processing.
> > 
> > The wrapping strategy seems to work ok. However there is a particular issue 
> > in detecting base64.StdEncoding versus base64.RawStdEncoding, which 
> > requires draining the io.Reader using base64.StdEncoding and (based on the 
> > current implementation) switching to base64.RawStdEncoding if an 
> > io.ErrUnexpectedEOF is found.
> > 

-- 
You received this message because you are subscribed to the Google Groups 
"golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to golang-nuts+unsubscr...@googlegroups.com.
To view this discussion visit 
https://groups.google.com/d/msgid/golang-nuts/Z4Qp1dPZGKKGU-ua%40campbell-lange.net.

Reply via email to