Move changes from exp2 to main
This is largely a move to simplify a lot of the readers Also further breaks out functions.
This commit is contained in:
@@ -0,0 +1,23 @@
|
||||
package toreader
|
||||
|
||||
import "io"
|
||||
|
||||
type ReaderAt struct {
|
||||
d []byte
|
||||
}
|
||||
|
||||
func NewReaderAt(r io.Reader) (ra ReaderAt, err error) {
|
||||
ra.d, err = io.ReadAll(r)
|
||||
return
|
||||
}
|
||||
|
||||
func (r ReaderAt) ReadAt(p []byte, off int64) (n int, err error) {
|
||||
if int(off) >= len(r.d) {
|
||||
return 0, io.EOF
|
||||
}
|
||||
n = copy(p, r.d[off:])
|
||||
if n != len(p) {
|
||||
err = io.EOF
|
||||
}
|
||||
return
|
||||
}
|
||||
Reference in New Issue
Block a user