1
0
mirror of https://github.com/golang/go synced 2024-11-16 22:54:47 -07:00
go/src/bufio
Bryan C. Mills 243d65c8e5 bufio: reject UnreadByte or UnreadRune after a Discard or WriteTo
Discard is not really a read operation, and in theory it could
Seek the underlying Reader without actually reading anything,
so an UnreadByte following a Discard is disallowed.

Similarly, although WriteTo usually does end up calling Read on the
underlying buffer, if the underlying Reader implements io.WriterTo it
may instead terminate in a call to WriteTo, without ever buffering or
even seeing the last byte written. (It is conceptually read-like, but
not strictly “a read operation”.)

Fixes #48446

Change-Id: Ide6f2b157332b423486810399f66140c914144e5
Reviewed-on: https://go-review.googlesource.com/c/go/+/351810
Trust: Bryan C. Mills <bcmills@google.com>
Trust: Joe Tsai <joetsai@digital-static.net>
Reviewed-by: Joe Tsai <joetsai@digital-static.net>
2021-10-01 17:40:49 +00:00
..
bufio_test.go bufio: reject UnreadByte or UnreadRune after a Discard or WriteTo 2021-10-01 17:40:49 +00:00
bufio.go bufio: reject UnreadByte or UnreadRune after a Discard or WriteTo 2021-10-01 17:40:49 +00:00
example_test.go bufio: add Writer.AvailableBuffer 2021-09-12 01:06:53 +00:00
export_test.go
scan_test.go
scan.go bufio: mention ErrFinalToken in SplitFunc documentation 2021-04-30 19:34:38 +00:00