Search Options

Results per page
Sort
Preferred Languages
Advance

Results 1 - 10 of 32 for Reset (0.22 sec)

  1. doc/next/6-stdlib/1-time.md

    now unbuffered, with capacity 0.
    The main effect of this change is that Go now guarantees
    that for any call to a `Reset` or `Stop` method, no stale values
    prepared before that call will be sent or received after the call.
    Earlier versions of Go used channels with a one-element buffer,
    making it difficult to use `Reset` and `Stop` correctly.
    A visible effect of this change is that `len` and `cap` of timer channels
    Plain Text
    - Registered: Tue Apr 23 11:13:09 GMT 2024
    - Last Modified: Fri Apr 12 20:57:18 GMT 2024
    - 1.5K bytes
    - Viewed (0)
  2. src/bytes/reader.go

    	}
    	r.i += int64(m)
    	n = int64(m)
    	if m != len(b) && err == nil {
    		err = io.ErrShortWrite
    	}
    	return
    }
    
    // Reset resets the [Reader.Reader] to be reading from b.
    func (r *Reader) Reset(b []byte) { *r = Reader{b, 0, -1} }
    
    // NewReader returns a new [Reader.Reader] reading from b.
    Go
    - Registered: Tue Apr 23 11:13:09 GMT 2024
    - Last Modified: Fri Oct 13 17:10:31 GMT 2023
    - 3.9K bytes
    - Viewed (0)
  3. src/archive/tar/writer.go

    			realSize := hdr.Size
    			hdr.Size = 0 // Encoded size; does not account for encoded sparse map
    			for _, s := range spd {
    				hdr.Size += s.Length
    			}
    			copy(blk.V7().Size(), zeroBlock[:]) // Reset field
    			f.formatNumeric(blk.V7().Size(), hdr.Size)
    			f.formatNumeric(blk.GNU().RealSize(), realSize)
    		}
    	*/
    	blk.setFormat(FormatGNU)
    	if err := tw.writeRawHeader(blk, hdr.Size, hdr.Typeflag); err != nil {
    Go
    - Registered: Tue Apr 23 11:13:09 GMT 2024
    - Last Modified: Fri Oct 13 18:36:46 GMT 2023
    - 19.6K bytes
    - Viewed (0)
  4. src/bytes/reader_test.go

    	}
    }
    
    func TestReaderReset(t *testing.T) {
    	r := NewReader([]byte("世界"))
    	if _, _, err := r.ReadRune(); err != nil {
    		t.Errorf("ReadRune: unexpected error: %v", err)
    	}
    
    	const want = "abcdef"
    	r.Reset([]byte(want))
    	if err := r.UnreadRune(); err == nil {
    		t.Errorf("UnreadRune: expected error, got nil")
    	}
    	buf, err := io.ReadAll(r)
    	if err != nil {
    		t.Errorf("ReadAll: unexpected error: %v", err)
    	}
    Go
    - Registered: Tue Apr 23 11:13:09 GMT 2024
    - Last Modified: Mon Dec 13 18:45:54 GMT 2021
    - 8K bytes
    - Viewed (0)
  5. src/bufio/bufio_test.go

    		t.Errorf("buf = %q; want foo", buf)
    	}
    
    	r.Reset(strings.NewReader("bar bar"))
    	checkAll(r, "bar bar")
    
    	*r = Reader{} // zero out the Reader
    	r.Reset(strings.NewReader("bar bar"))
    	checkAll(r, "bar bar")
    
    	// Wrap a reader and then Reset to that reader.
    	r.Reset(strings.NewReader("recur"))
    	r2 := NewReader(r)
    	checkAll(r2, "recur")
    	r.Reset(strings.NewReader("recur2"))
    	r2.Reset(r)
    Go
    - Registered: Tue Apr 23 11:13:09 GMT 2024
    - Last Modified: Fri Feb 10 18:56:01 GMT 2023
    - 51.5K bytes
    - Viewed (0)
  6. src/bytes/buffer_test.go

    	buf := NewBuffer(make([]byte, n))
    	for i := 0; i < b.N; i++ {
    		buf.Reset()
    		for i := 0; i < n; i++ {
    			buf.WriteByte('x')
    		}
    	}
    }
    
    func BenchmarkWriteRune(b *testing.B) {
    	const n = 4 << 10
    	const r = '☺'
    	b.SetBytes(int64(n * utf8.RuneLen(r)))
    	buf := NewBuffer(make([]byte, n*utf8.UTFMax))
    	for i := 0; i < b.N; i++ {
    		buf.Reset()
    		for i := 0; i < n; i++ {
    			buf.WriteRune(r)
    		}
    	}
    }
    Go
    - Registered: Tue Apr 23 11:13:09 GMT 2024
    - Last Modified: Thu Apr 20 01:07:29 GMT 2023
    - 18.1K bytes
    - Viewed (0)
  7. src/archive/tar/format.go

    			c = ' ' // Treat the checksum field itself as all spaces.
    		}
    		unsigned += int64(c)
    		signed += int64(int8(c))
    	}
    	return unsigned, signed
    }
    
    // reset clears the block with all zeros.
    func (b *block) reset() {
    	*b = block{}
    }
    
    type headerV7 [blockSize]byte
    
    func (h *headerV7) name() []byte     { return h[000:][:100] }
    func (h *headerV7) mode() []byte     { return h[100:][:8] }
    Go
    - Registered: Tue Apr 23 11:13:09 GMT 2024
    - Last Modified: Fri Oct 13 18:36:46 GMT 2023
    - 11.3K bytes
    - Viewed (0)
  8. doc/godebug.md

    ### Go 1.23
    
    Go 1.23 changed the channels created by package time to be unbuffered
    (synchronous), which makes correct use of the [`Timer.Stop`](/pkg/time/#Timer.Stop)
    and [`Timer.Reset`](/pkg/time/#Timer.Reset) method results much easier.
    The [`asynctimerchan` setting](/pkg/time/#NewTimer) disables this change.
    There are no runtime metrics for this change,
    Plain Text
    - Registered: Tue Apr 23 11:13:09 GMT 2024
    - Last Modified: Tue Apr 16 17:29:58 GMT 2024
    - 13.5K bytes
    - Viewed (0)
  9. src/cmd/cgo/godefs.go

    	conf.Fprint(&buf, fset, f.AST)
    
    	return buf.String()
    }
    
    var gofmtBuf strings.Builder
    
    // gofmt returns the gofmt-formatted string for an AST node.
    func gofmt(n interface{}) string {
    	gofmtBuf.Reset()
    	err := printer.Fprint(&gofmtBuf, fset, n)
    	if err != nil {
    		return "<" + err.Error() + ">"
    	}
    	return gofmtBuf.String()
    }
    
    // gofmtLineReplacer is used to put a gofmt-formatted string for an
    Go
    - Registered: Tue Apr 23 11:13:09 GMT 2024
    - Last Modified: Thu Sep 08 14:33:35 GMT 2022
    - 4.5K bytes
    - Viewed (0)
  10. src/bytes/buffer.go

    func (b *Buffer) Truncate(n int) {
    	if n == 0 {
    		b.Reset()
    		return
    	}
    	b.lastRead = opInvalid
    	if n < 0 || n > b.Len() {
    		panic("bytes.Buffer: truncation out of range")
    	}
    	b.buf = b.buf[:b.off+n]
    }
    
    // Reset resets the buffer to be empty,
    // but it retains the underlying storage for use by future writes.
    // Reset is the same as [Buffer.Truncate](0).
    func (b *Buffer) Reset() {
    	b.buf = b.buf[:0]
    	b.off = 0
    Go
    - Registered: Tue Apr 23 11:13:09 GMT 2024
    - Last Modified: Fri Oct 13 17:10:31 GMT 2023
    - 15.7K bytes
    - Viewed (0)
Back to top