- Sort Score
- Result 10 results
- Languages All
Results 1 - 10 of 24 for copyBuffer (0.23 sec)
-
src/compress/flate/writer_test.go
copyBuffer := make([]byte, 128) for l := 0; l < 10; l++ { for fail := 1; fail <= 256; fail *= 2 { // Fail after 'fail' writes ew := &errorWriter{N: fail} w, err := NewWriter(ew, l) if err != nil { t.Fatalf("NewWriter: level %d: %v", l, err) } n, err := io.CopyBuffer(w, struct{ io.Reader }{bytes.NewBuffer(in)}, copyBuffer) if err == nil {
Registered: Wed Jun 12 16:32:35 UTC 2024 - Last Modified: Tue Oct 20 18:41:18 UTC 2020 - 5.4K bytes - Viewed (0) -
src/io/io.go
func CopyBuffer(dst Writer, src Reader, buf []byte) (written int64, err error) { if buf != nil && len(buf) == 0 { panic("empty buffer in CopyBuffer") } return copyBuffer(dst, src, buf) } // copyBuffer is the actual implementation of Copy and CopyBuffer. // if buf is nil, one is allocated. func copyBuffer(dst Writer, src Reader, buf []byte) (written int64, err error) {
Registered: Wed Jun 12 16:32:35 UTC 2024 - Last Modified: Mon Apr 15 17:34:10 UTC 2024 - 21.6K bytes - Viewed (0) -
src/io/example_test.go
r2 := strings.NewReader("second reader\n") buf := make([]byte, 8) // buf is used here... if _, err := io.CopyBuffer(os.Stdout, r1, buf); err != nil { log.Fatal(err) } // ... reused here also. No need to allocate an extra buffer. if _, err := io.CopyBuffer(os.Stdout, r2, buf); err != nil { log.Fatal(err) } // Output: // first reader // second reader }
Registered: Wed Jun 12 16:32:35 UTC 2024 - Last Modified: Tue Sep 06 15:49:32 UTC 2022 - 5.5K bytes - Viewed (0) -
src/io/io_test.go
rb := new(Buffer) wb := new(Buffer) rb.WriteString("hello, world.") CopyBuffer(wb, rb, make([]byte, 1)) // Tiny buffer to keep it honest. if wb.String() != "hello, world." { t.Errorf("CopyBuffer did not work properly") } } func TestCopyBufferNil(t *testing.T) { rb := new(Buffer) wb := new(Buffer) rb.WriteString("hello, world.") CopyBuffer(wb, rb, nil) // Should allocate a buffer. if wb.String() != "hello, world." {
Registered: Wed Jun 12 16:32:35 UTC 2024 - Last Modified: Mon Oct 09 22:04:41 UTC 2023 - 18.9K bytes - Viewed (0) -
src/encoding/hex/hex_test.go
output := strings.Repeat(test.enc, multiplier) var buf bytes.Buffer enc := NewEncoder(&buf) r := struct{ io.Reader }{bytes.NewReader(input)} // io.Reader only; not io.WriterTo if n, err := io.CopyBuffer(enc, r, make([]byte, 7)); n != int64(len(input)) || err != nil { t.Errorf("encoder.Write(%q*%d) = (%d, %v), want (%d, nil)", test.dec, multiplier, n, err, len(input)) continue }
Registered: Wed Jun 12 16:32:35 UTC 2024 - Last Modified: Wed May 08 19:30:23 UTC 2024 - 7.9K bytes - Viewed (0) -
src/compress/flate/example_test.go
zw.Reset(&b) if _, err := io.CopyBuffer(zw, &r, buf); err != nil { log.Fatal(err) } if err := zw.Close(); err != nil { log.Fatal(err) } // Reset the decompressor and decode to some output stream. if err := zr.(flate.Resetter).Reset(&b, nil); err != nil { log.Fatal(err) } if _, err := io.CopyBuffer(os.Stdout, zr, buf); err != nil { log.Fatal(err) }
Registered: Wed Jun 12 16:32:35 UTC 2024 - Last Modified: Sat Nov 12 18:42:35 UTC 2016 - 6.5K bytes - Viewed (0) -
src/net/http/httputil/reverseproxy.go
var buf []byte if p.BufferPool != nil { buf = p.BufferPool.Get() defer p.BufferPool.Put(buf) } _, err := p.copyBuffer(w, src, buf) return err } // copyBuffer returns any write errors or non-EOF read errors, and the amount // of bytes written. func (p *ReverseProxy) copyBuffer(dst io.Writer, src io.Reader, buf []byte) (int64, error) { if len(buf) == 0 { buf = make([]byte, 32*1024) }
Registered: Wed Jun 12 16:32:35 UTC 2024 - Last Modified: Tue Feb 27 23:37:42 UTC 2024 - 24.9K bytes - Viewed (0) -
src/io/multi.go
for i, r := range mr.readers { var n int64 if subMr, ok := r.(*multiReader); ok { // reuse buffer with nested multiReaders n, err = subMr.writeToWithBuffer(w, buf) } else { n, err = copyBuffer(w, r, buf) } sum += n if err != nil { mr.readers = mr.readers[i:] // permit resume / retry after error return sum, err } mr.readers[i] = nil // permit early GC } mr.readers = nil
Registered: Wed Jun 12 16:32:35 UTC 2024 - Last Modified: Thu May 19 15:49:05 UTC 2022 - 3.3K bytes - Viewed (0) -
pkg/hbone/util.go
bufCap := cap(buf1) buf := buf1[0:bufCap:bufCap] // For netstack: src is a gonet.Conn, doesn't implement WriterTo. Dst is a net.TcpConn - and implements ReadFrom. // CopyBuffered is the actual implementation of Copy and CopyBuffer. // if buf is nil, one is allocated. // Duplicated from io // This will prevent stats from working. // If the reader has a WriteTo method, use it to do the copy. // Avoids an allocation and a copy.
Registered: Fri Jun 14 15:00:06 UTC 2024 - Last Modified: Tue May 23 17:08:31 UTC 2023 - 3.4K bytes - Viewed (0) -
cmd/bitrot.go
// Read's failed for object with right size, file is corrupt. return err } // Subtract hash length.. left -= int64(n) if left < shardSize { shardSize = left } read, err := io.CopyBuffer(h, io.LimitReader(r, shardSize), *bufp) if err != nil { // Read's failed for object with right size, at different offsets. return errFileCorrupt } left -= read
Registered: Sun Jun 16 00:44:34 UTC 2024 - Last Modified: Tue Jan 30 20:43:25 UTC 2024 - 7.6K bytes - Viewed (0)