- Sort Score
- Result 10 results
- Languages All
Results 1 - 10 of 21 for copyBuffer (0.18 sec)
-
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/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) -
src/mime/multipart/formdata.go
} // os.File.ReadFrom will allocate its own copy buffer if we let io.Copy use it. type writerOnly struct{ io.Writer } remainingSize, err := io.CopyBuffer(writerOnly{file}, p, copyBuf) if err != nil { return nil, err } fh.tmpfile = file.Name() fh.Size = int64(b.Len()) + remainingSize fh.tmpoff = fileOff fileOff += fh.Size
Registered: Wed Jun 12 16:32:35 UTC 2024 - Last Modified: Thu Mar 21 16:12:35 UTC 2024 - 7.7K bytes - Viewed (0) -
cmd/object-api-utils_test.go
r, idxCB := newS2CompressReader(bytes.NewReader(tt.data), int64(len(tt.data)), false) defer r.Close() var rdrBuf bytes.Buffer _, err := io.CopyBuffer(&rdrBuf, r, buf) if err != nil { t.Fatal(err) } r.Close() idx := idxCB() if !tt.wantIdx && len(idx) > 0 { t.Errorf("index returned above threshold") } if tt.wantIdx {
Registered: Sun Jun 16 00:44:34 UTC 2024 - Last Modified: Fri May 24 23:05:23 UTC 2024 - 23.4K bytes - Viewed (0)