| 1 | package bufferscip-go gomod github.com/djherbis/buffer . `github.com/djherbis/buffer`/ |
| 2 | |
| 3 | import ( |
| 4 | "bytesscip-go gomod github.com/golang/go/src go1.13 bytes/" |
| 5 | "encoding/gobscip-go gomod github.com/golang/go/src go1.13 `encoding/gob`/" |
| 6 | "fmtscip-go gomod github.com/golang/go/src go1.13 fmt/" |
| 7 | "ioscip-go gomod github.com/golang/go/src go1.13 io/" |
| 8 | |
| 9 | "github.com/djherbis/buffer/limioscip-go gomod github.com/djherbis/buffer . `github.com/djherbis/buffer/limio`/" |
| 10 | ) |
| 11 | |
| 12 | type memoryscip-go gomod github.com/djherbis/buffer . `github.com/djherbis/buffer`/memory# struct { |
| 13 | Nscip-go gomod github.com/djherbis/buffer . `github.com/djherbis/buffer`/memory#N. int64 |
| 14 | *bytesscip-go gomod github.com/golang/go/src go1.13 bytes/.Bufferscip-go gomod github.com/djherbis/buffer . `github.com/djherbis/buffer`/memory#Buffer. |
| 15 | } |
| 16 | |
| 17 | // New returns a new in memory BufferAt with max size N. |
| 18 | // It's backed by a bytes.Buffer. |
| 19 | func Newscip-go gomod github.com/djherbis/buffer . `github.com/djherbis/buffer`/New().(n int64) BufferAtscip-go gomod github.com/djherbis/buffer . `github.com/djherbis/buffer`/BufferAt# { |
| 20 | return &memoryscip-go gomod github.com/djherbis/buffer . `github.com/djherbis/buffer`/memory#{ |
| 21 | Nscip-go gomod github.com/djherbis/buffer . `github.com/djherbis/buffer`/memory#N.: n, |
| 22 | Bufferscip-go gomod github.com/djherbis/buffer . `github.com/djherbis/buffer`/memory#Buffer.: bytesscip-go gomod github.com/golang/go/src go1.13 bytes/.NewBufferscip-go gomod github.com/golang/go/src go1.13 bytes/NewBuffer().(nil), |
| 23 | } |
| 24 | } |
| 25 | |
| 26 | func (buf *memoryscip-go gomod github.com/djherbis/buffer . `github.com/djherbis/buffer`/memory#) Capscip-go gomod github.com/djherbis/buffer . `github.com/djherbis/buffer`/memory#Cap().() int64 { |
| 27 | return buf.Nscip-go gomod github.com/djherbis/buffer . `github.com/djherbis/buffer`/memory#N. |
| 28 | } |
| 29 | |
| 30 | func (buf *memoryscip-go gomod github.com/djherbis/buffer . `github.com/djherbis/buffer`/memory#) Lenscip-go gomod github.com/djherbis/buffer . `github.com/djherbis/buffer`/memory#Len().() int64 { |
| 31 | return int64(buf.Bufferscip-go gomod github.com/djherbis/buffer . `github.com/djherbis/buffer`/memory#Buffer..Lenscip-go gomod github.com/golang/go/src go1.13 bytes/Buffer#Len().()) |
| 32 | } |
| 33 | |
| 34 | func (buf *memoryscip-go gomod github.com/djherbis/buffer . `github.com/djherbis/buffer`/memory#) Writescip-go gomod github.com/djherbis/buffer . `github.com/djherbis/buffer`/memory#Write().(p []byte) (n int, err error) { |
| 35 | return limioscip-go gomod github.com/djherbis/buffer . `github.com/djherbis/buffer/limio`/.LimitWriterscip-go gomod github.com/djherbis/buffer . `github.com/djherbis/buffer/limio`/LimitWriter().(buf.Bufferscip-go gomod github.com/djherbis/buffer . `github.com/djherbis/buffer`/memory#Buffer., Gapscip-go gomod github.com/djherbis/buffer . `github.com/djherbis/buffer`/Gap().(buf)).Writescip-go gomod github.com/golang/go/src go1.13 io/Writer#Write().(p) |
| 36 | } |
| 37 | |
| 38 | func (buf *memoryscip-go gomod github.com/djherbis/buffer . `github.com/djherbis/buffer`/memory#) WriteAtscip-go gomod github.com/djherbis/buffer . `github.com/djherbis/buffer`/memory#WriteAt().(p []byte, off int64) (n int, err error) { |
| 39 | if off > buf.Lenscip-go gomod github.com/djherbis/buffer . `github.com/djherbis/buffer`/memory#Len().() { |
| 40 | return 0, ioscip-go gomod github.com/golang/go/src go1.13 io/.ErrShortWritescip-go gomod github.com/golang/go/src go1.13 io/ErrShortWrite. |
| 41 | } else if len64scip-go gomod github.com/djherbis/buffer . `github.com/djherbis/buffer`/len64().(p)+off <= buf.Lenscip-go gomod github.com/djherbis/buffer . `github.com/djherbis/buffer`/memory#Len().() { |
| 42 | d := buf.Bytesscip-go gomod github.com/golang/go/src go1.13 bytes/Buffer#Bytes().()[off:] |
| 43 | return copy(d, p), nil |
| 44 | } else { |
| 45 | d := buf.Bytesscip-go gomod github.com/golang/go/src go1.13 bytes/Buffer#Bytes().()[off:] |
| 46 | n = copy(d, p) |
| 47 | m, err := buf.Writescip-go gomod github.com/djherbis/buffer . `github.com/djherbis/buffer`/memory#Write().(p[n:]) |
| 48 | return n + m, err |
| 49 | } |
| 50 | } |
| 51 | |
| 52 | func (buf *memoryscip-go gomod github.com/djherbis/buffer . `github.com/djherbis/buffer`/memory#) ReadAtscip-go gomod github.com/djherbis/buffer . `github.com/djherbis/buffer`/memory#ReadAt().(p []byte, off int64) (n int, err error) { |
| 53 | return bytesscip-go gomod github.com/golang/go/src go1.13 bytes/.NewReaderscip-go gomod github.com/golang/go/src go1.13 bytes/NewReader().(buf.Bytesscip-go gomod github.com/golang/go/src go1.13 bytes/Buffer#Bytes().()).ReadAtscip-go gomod github.com/golang/go/src go1.13 bytes/Reader#ReadAt().(p, off) |
| 54 | } |
| 55 | |
| 56 | func (buf *memoryscip-go gomod github.com/djherbis/buffer . `github.com/djherbis/buffer`/memory#) Readscip-go gomod github.com/djherbis/buffer . `github.com/djherbis/buffer`/memory#Read().(p []byte) (n int, err error) { |
| 57 | return ioscip-go gomod github.com/golang/go/src go1.13 io/.LimitReaderscip-go gomod github.com/golang/go/src go1.13 io/LimitReader().(buf.Bufferscip-go gomod github.com/djherbis/buffer . `github.com/djherbis/buffer`/memory#Buffer., buf.Lenscip-go gomod github.com/djherbis/buffer . `github.com/djherbis/buffer`/memory#Len().()).Readscip-go gomod github.com/golang/go/src go1.13 io/Reader#Read().(p) |
| 58 | } |
| 59 | |
| 60 | func (buf *memoryscip-go gomod github.com/djherbis/buffer . `github.com/djherbis/buffer`/memory#) ReadFromscip-go gomod github.com/djherbis/buffer . `github.com/djherbis/buffer`/memory#ReadFrom().(r ioscip-go gomod github.com/golang/go/src go1.13 io/.Readerscip-go gomod github.com/golang/go/src go1.13 io/Reader#) (n int64, err error) { |
| 61 | return buf.Bufferscip-go gomod github.com/djherbis/buffer . `github.com/djherbis/buffer`/memory#Buffer..ReadFromscip-go gomod github.com/golang/go/src go1.13 bytes/Buffer#ReadFrom().(ioscip-go gomod github.com/golang/go/src go1.13 io/.LimitReaderscip-go gomod github.com/golang/go/src go1.13 io/LimitReader().(r, Gapscip-go gomod github.com/djherbis/buffer . `github.com/djherbis/buffer`/Gap().(buf))) |
| 62 | } |
| 63 | |
| 64 | func initscip-go gomod github.com/djherbis/buffer . `github.com/djherbis/buffer`/init().() { |
| 65 | gobscip-go gomod github.com/golang/go/src go1.13 `encoding/gob`/.Registerscip-go gomod github.com/golang/go/src go1.13 `encoding/gob`/Register().(&memoryscip-go gomod github.com/djherbis/buffer . `github.com/djherbis/buffer`/memory#{}) |
| 66 | } |
| 67 | |
| 68 | func (buf *memoryscip-go gomod github.com/djherbis/buffer . `github.com/djherbis/buffer`/memory#) MarshalBinaryscip-go gomod github.com/djherbis/buffer . `github.com/djherbis/buffer`/memory#MarshalBinary().() ([]byte, error) { |
| 69 | var b bytesscip-go gomod github.com/golang/go/src go1.13 bytes/.Bufferscip-go gomod github.com/golang/go/src go1.13 bytes/Buffer# |
| 70 | fmtscip-go gomod github.com/golang/go/src go1.13 fmt/.Fprintlnscip-go gomod github.com/golang/go/src go1.13 fmt/Fprintln().(&b, buf.Nscip-go gomod github.com/djherbis/buffer . `github.com/djherbis/buffer`/memory#N.) |
| 71 | b.Writescip-go gomod github.com/golang/go/src go1.13 bytes/Buffer#Write().(buf.Bytesscip-go gomod github.com/golang/go/src go1.13 bytes/Buffer#Bytes().()) |
| 72 | return b.Bytesscip-go gomod github.com/golang/go/src go1.13 bytes/Buffer#Bytes().(), nil |
| 73 | } |
| 74 | |
| 75 | func (buf *memoryscip-go gomod github.com/djherbis/buffer . `github.com/djherbis/buffer`/memory#) UnmarshalBinaryscip-go gomod github.com/djherbis/buffer . `github.com/djherbis/buffer`/memory#UnmarshalBinary().(bindata []byte) error { |
| 76 | data := make([]byte, len(bindata)) |
| 77 | copy(data, bindata) |
| 78 | b := bytesscip-go gomod github.com/golang/go/src go1.13 bytes/.NewBufferscip-go gomod github.com/golang/go/src go1.13 bytes/NewBuffer().(data) |
| 79 | _, err := fmtscip-go gomod github.com/golang/go/src go1.13 fmt/.Fscanlnscip-go gomod github.com/golang/go/src go1.13 fmt/Fscanln().(b, &buf.Nscip-go gomod github.com/djherbis/buffer . `github.com/djherbis/buffer`/memory#N.) |
| 80 | buf.Bufferscip-go gomod github.com/djherbis/buffer . `github.com/djherbis/buffer`/memory#Buffer. = bytesscip-go gomod github.com/golang/go/src go1.13 bytes/.NewBufferscip-go gomod github.com/golang/go/src go1.13 bytes/NewBuffer().(b.Bytesscip-go gomod github.com/golang/go/src go1.13 bytes/Buffer#Bytes().()) |
| 81 | return err |
| 82 | } |