Suppose you (okay, okay, I) want something like an io.SectionReader but 
don't want to specify the end point of the section, just the start.  That 
is, method calls to Read should only return EOF when at the end of the 
underlying source of the initially supplied io.ReaderAt. This can be 
achieved, I suppose, by using an io.SectionReader with n set to the maximum 
value of an int64.  Is this often done?  Or (assuming here that only the 
Read method is needed) should I simply create something like:

func newWhenceReader(r io.ReaderAt, off int64) io.Reader {
        return &whenceReader{r, off}
}

type whenceReader struct {
        r        ReaderAt
        off     int64
}

// I would otherwise use 'w' (for whence) for the receiver,
// but it feels funny using 'w' for something that reads.
func (r *whenceReader) Read(p []byte) (n int, err error) {
        n, err = r.r.ReadAt(p, r.off)
        r.off += int64(n)
        return
}

-- 
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 on the web visit 
https://groups.google.com/d/msgid/golang-nuts/e50a7c0b-3a42-49d5-9e24-cdf83497bcbc%40googlegroups.com.

Reply via email to