bufio: make buffer documentation concise

This commit is contained in:
Lokesh Kumar 2025-05-21 16:41:30 +02:00
parent d77d98f8de
commit 4b4c7595d5

View file

@ -260,11 +260,10 @@ func (s *Scanner) setErr(err error) {
}
}
// Buffer sets the initial buffer to use when scanning
// Buffer controls memory allocation by the Scanner.
// It sets the initial buffer to use when scanning
// and the maximum size of buffer that may be allocated during scanning.
// The buffer is used internally by the Scanner and should not be used to provide
// input data to the scanner. The scanner reads input data exclusively from the
// io.Reader provided to [NewScanner].
// The contents of the buffer are ignored.
//
// The maximum token size must be less than the larger of max and cap(buf).
// If max <= cap(buf), [Scanner.Scan] will use this buffer only and do no allocation.
@ -273,11 +272,6 @@ func (s *Scanner) setErr(err error) {
// maximum token size to [MaxScanTokenSize].
//
// Buffer panics if it is called after scanning has started.
//
// To provide initial data to the scanner, wrap the io.Reader passed to [NewScanner]
// using [io.MultiReader]. For example:
// initial := bytes.NewReader([]byte("initial data\n"))
// scanner := bufio.NewScanner(io.MultiReader(initial, os.Stdin))
func (s *Scanner) Buffer(buf []byte, max int) {
if s.scanCalled {
panic("Buffer called after Scan")