The type definition above should read: type whenceReader struct { r io.ReaderAt off int64 }
(I forgot to put the package name (i.e., "io." in front of ReaderAt.) On Sunday, December 8, 2019 at 6:19:04 PM UTC-5, William Hanisch wrote: > > 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/244620d0-b4a4-4793-b066-03ef0adf8b81%40googlegroups.com.