aboutsummaryrefslogtreecommitdiff
path: root/src/bufio/bufio.go
AgeCommit message (Collapse)Author
17 hoursbufio: realign struct ReaderShulhan
This reduce the Reader allocation size from 72 to 40 bytes and Writer allocation size from 64 to 40 bytes.
2026-02-06bufio: fix doc link to Reset methodMichal Bohuslávek
On https://pkg.go.dev/bufio#Reader, the reference to the Reset method is rendered as [Reset]. Fix it by referring to the method via its type. Change-Id: I4256ca80ebef7b850e6a97b96503dd7178cb361b Reviewed-on: https://go-review.googlesource.com/c/go/+/736320 LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Reviewed-by: Daniel Morsing <daniel.morsing@gmail.com> Auto-Submit: Michael Knyszek <mknyszek@google.com> Reviewed-by: Robert Griesemer <gri@google.com> Reviewed-by: Michael Knyszek <mknyszek@google.com>
2025-09-03unicode/utf8: make DecodeRune{,InString} inlineableJulien Cretel
This change makes the fast path for ASCII characters inlineable in DecodeRune and DecodeRuneInString and removes most instances of manual inlining at call sites. Here are some benchmark results (no change to allocations): goos: darwin goarch: amd64 pkg: unicode/utf8 cpu: Intel(R) Core(TM) i7-6700HQ CPU @ 2.60GHz │ old │ new │ │ sec/op │ sec/op vs base │ DecodeASCIIRune-8 2.4545n ± 2% 0.6253n ± 2% -74.52% (p=0.000 n=20) DecodeJapaneseRune-8 3.988n ± 1% 4.023n ± 1% +0.86% (p=0.050 n=20) DecodeASCIIRuneInString-8 2.4675n ± 1% 0.6264n ± 2% -74.61% (p=0.000 n=20) DecodeJapaneseRuneInString-8 3.992n ± 1% 4.001n ± 1% ~ (p=0.625 n=20) geomean 3.134n 1.585n -49.43% Note: when #61502 gets resolved, DecodeRune and DecodeRuneInString should be reverted to their idiomatic implementations. Fixes #31666 Updates #48195 Change-Id: I4be25c4f52417dc28b3a7bd72f1b04018470f39d GitHub-Last-Rev: 2e352a0045027e059be79cdb60241b5cf35fec71 GitHub-Pull-Request: golang/go#75181 Reviewed-on: https://go-review.googlesource.com/c/go/+/699675 Reviewed-by: Sean Liao <sean@liao.dev> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Reviewed-by: Cherry Mui <cherryyz@google.com> Reviewed-by: Michael Pratt <mpratt@google.com>
2025-02-06bufio: don't do empty Write at start of WriteToIan Lance Taylor
The empty Write will cause the wrong thing to happen when using io.Copy to copy to a package-based stream. Fixes #71424 Change-Id: I046a27539447182692ac76a8bdd422327345dd8d Reviewed-on: https://go-review.googlesource.com/c/go/+/644535 Reviewed-by: Keith Randall <khr@golang.org> Reviewed-by: Michael Knyszek <mknyszek@google.com> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Reviewed-by: Keith Randall <khr@google.com> Auto-Submit: Ian Lance Taylor <iant@golang.org> Reviewed-by: Mauri de Souza Meneguzzo <mauri870@gmail.com> Reviewed-by: Damien Neil <dneil@google.com>
2024-12-09bufio: make the description of Peek's behavior betterPetr Osetrov
Previously, based on the description, it was not obvious that Peek could change the buffer. It may have been mistakenly assumed that Peek would always return an error if n is greater than b.Buffered(). Change-Id: I095006dd2ba1c2138bb193396cb24e2dda42d771 GitHub-Last-Rev: 9d48f8ac81f46d5b8f4a1885af28cbccd1747c3b GitHub-Pull-Request: golang/go#70712 Reviewed-on: https://go-review.googlesource.com/c/go/+/634175 Reviewed-by: Carlos Amedee <carlos@golang.org> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Auto-Submit: Ian Lance Taylor <iant@google.com> Reviewed-by: Ian Lance Taylor <iant@google.com> Reviewed-by: Jorropo <jorropo.pgm@gmail.com>
2024-12-04bufio: document Reader must be created with New functionsSean Liao
Fixes #37347 Change-Id: Id642dbe7e52933f8d6cf7116c3c27ddb74efba9d Reviewed-on: https://go-review.googlesource.com/c/go/+/633315 LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Reviewed-by: Robert Griesemer <gri@google.com> Reviewed-by: Michael Knyszek <mknyszek@google.com>
2023-10-12bufio: add available godoc linkcui fliter
Change-Id: Id32bae57c9fcc2074f82089ba9c69be9a601f128 Reviewed-on: https://go-review.googlesource.com/c/go/+/534758 Reviewed-by: Dmitri Shuralyov <dmitshur@google.com> Run-TryBot: shuang cui <imcusg@gmail.com> Reviewed-by: Ian Lance Taylor <iant@google.com> Auto-Submit: Ian Lance Taylor <iant@google.com> TryBot-Result: Gopher Robot <gobot@golang.org>
2023-10-04bufio: use max/min funcqiulaidongfeng
Change-Id: I52875f8dd4bbdc9296ba8e4f801356047ee14e62 GitHub-Last-Rev: dfb2a343e60f0994a5741e1b4534e464a80ba2ef GitHub-Pull-Request: golang/go#63344 Reviewed-on: https://go-review.googlesource.com/c/go/+/532216 Reviewed-by: Robert Griesemer <gri@google.com> Reviewed-by: Keith Randall <khr@golang.org> TryBot-Result: Gopher Robot <gobot@golang.org> Reviewed-by: Keith Randall <khr@google.com> Run-TryBot: Robert Griesemer <gri@google.com> Auto-Submit: Robert Griesemer <gri@google.com>
2023-02-10bufio: permit r.Reset(r) without infinite recursionIan Lance Taylor
This can happen in reasonable code because NewReader(r) can return r, if r is already a Reader. Similarly for Writer. Fixes #58423 Change-Id: Iff9d9265410bee68fbaeb7175369847bd737eb2c Reviewed-on: https://go-review.googlesource.com/c/go/+/466815 Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org> TryBot-Result: Gopher Robot <gobot@golang.org> Auto-Submit: Ian Lance Taylor <iant@google.com> Reviewed-by: Bryan Mills <bcmills@google.com> Run-TryBot: Ian Lance Taylor <iant@google.com> Reviewed-by: Ian Lance Taylor <iant@google.com> Run-TryBot: Ian Lance Taylor <iant@golang.org>
2022-09-27bufio: use bytes.Clonecuiweixie
Change-Id: Ic21d979da8be1a6047b9bcd65b5ee71ca2ef7548 Reviewed-on: https://go-review.googlesource.com/c/go/+/435278 Reviewed-by: Robert Griesemer <gri@google.com> Auto-Submit: Ian Lance Taylor <iant@google.com> Run-TryBot: Ian Lance Taylor <iant@google.com> TryBot-Result: Gopher Robot <gobot@golang.org> Reviewed-by: Ian Lance Taylor <iant@google.com>
2022-05-02bufio: clarify io.EOF behavior of Reader.ReadIan Lance Taylor
Fixes #52577 Change-Id: Idaff2604979f9a9c1c7d3140c8a5d218fcd27a56 Reviewed-on: https://go-review.googlesource.com/c/go/+/403594 Reviewed-by: Joseph Tsai <joetsai@digital-static.net> Reviewed-by: Ian Lance Taylor <iant@google.com> Auto-Submit: Ian Lance Taylor <iant@google.com> Reviewed-by: Bryan Mills <bcmills@google.com> Run-TryBot: Ian Lance Taylor <iant@golang.org> TryBot-Result: Gopher Robot <gobot@golang.org> Run-TryBot: Ian Lance Taylor <iant@google.com>
2022-04-21bufio: implement large write forwarding in Writer.WriteStringCarlo Alberto Ferraris
Currently bufio.Writer implements forwarding to the underlying Writer for large writes via Write, but it does not do the same for large writes via WriteString. If the underlying Writer is also a StringWriter, use the same "large writes" logic also in WriteString while taking care to only check once per call to WriteString whether the underlying Writer implements StringWriter. Change-Id: Id81901c07b035936816b9e41b1f5688e699ee8e9 Reviewed-on: https://go-review.googlesource.com/c/go/+/380074 Reviewed-by: Ian Lance Taylor <iant@google.com> Run-TryBot: Ian Lance Taylor <iant@google.com> Auto-Submit: Ian Lance Taylor <iant@google.com> TryBot-Result: Gopher Robot <gobot@golang.org> Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
2021-11-26bufio: mention that panic at slicing means underlying reader is brokenKeith Randall
Fixes #49795 Change-Id: I2b4fd14f0ed36b643522559bebf5ce52b1d7b304 Reviewed-on: https://go-review.googlesource.com/c/go/+/367214 Trust: Keith Randall <khr@golang.org> Run-TryBot: Keith Randall <khr@golang.org> TryBot-Result: Go Bot <gobot@golang.org> Reviewed-by: Ian Lance Taylor <iant@golang.org>
2021-11-09bufio: document that NewWriter can return its argumentIan Lance Taylor
Fixes #49446 Change-Id: Ib0b53a7dd5d567a2dd0bdf29f53d276587b60afb Reviewed-on: https://go-review.googlesource.com/c/go/+/361921 Trust: Ian Lance Taylor <iant@golang.org> Run-TryBot: Ian Lance Taylor <iant@golang.org> TryBot-Result: Go Bot <gobot@golang.org> Reviewed-by: Tobias Klauser <tobias.klauser@gmail.com>
2021-10-18bufio: use underlying ReadFrom even when data is bufferedDamien Neil
When (*bufio.Writer).ReadFrom is called with a partially filled buffer, fill out and flush the buffer and then call the underlying writer's ReadFrom method if present. Fixes #44815. Change-Id: I15b3ef0746d0d60fd62041189a9b9df11254dd29 Reviewed-on: https://go-review.googlesource.com/c/go/+/340530 Trust: Damien Neil <dneil@google.com> Run-TryBot: Damien Neil <dneil@google.com> TryBot-Result: Go Bot <gobot@golang.org> Reviewed-by: Ian Lance Taylor <iant@golang.org>
2021-10-01bufio: reject UnreadByte or UnreadRune after a Discard or WriteToBryan C. Mills
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-09-12bufio: add Writer.AvailableBufferJoe Tsai
This adds a new Writer.AvailableBuffer method that returns an empty buffer with a possibly non-empty capacity for use with append-like APIs. The typical usage pattern is something like: b := bw.AvailableBuffer() b = appendValue(b, v) bw.Write(b) It allows logic combining append-like APIs with bufio.Writer to avoid needing to allocate and manage buffers themselves and allows the append-like APIs to directly write into the buffer for a bufio.Writer. Fixes #47527 Change-Id: I9cd169f3f8e8c7cd40818caf3daf1944c826fc66 Reviewed-on: https://go-review.googlesource.com/c/go/+/345569 Trust: Joe Tsai <joetsai@digital-static.net> Run-TryBot: Joe Tsai <joetsai@digital-static.net> TryBot-Result: Go Bot <gobot@golang.org> Reviewed-by: Ian Lance Taylor <iant@golang.org>
2021-09-11bufio: make Reader.Reset and Writer.Reset work on the zero valueJoe Tsai
For batch allocation reasons, it would be useful to nest a bufio.Reader or bufio.Writer in a struct as a value, rather than a pointer. When the Reset method is called, have it use the default buffer size if the buffer is nil. Fixes #45374 Change-Id: I80df18a13575431428a42ed150a1579de1282637 Reviewed-on: https://go-review.googlesource.com/c/go/+/345570 Trust: Joe Tsai <joetsai@digital-static.net> Run-TryBot: Joe Tsai <joetsai@digital-static.net> TryBot-Result: Go Bot <gobot@golang.org> Reviewed-by: Ian Lance Taylor <iant@golang.org>
2021-02-24bufio, bytes, strings: handle negative runes in WriteRuneDavid Benjamin
Updates #43254 Change-Id: I7d4bf3b99cc36ca2156af5bb01a1c595419d1d3c Reviewed-on: https://go-review.googlesource.com/c/go/+/280492 Reviewed-by: Emmanuel Odeke <emmanuel@orijtech.com> Reviewed-by: Rob Pike <r@golang.org> Trust: Emmanuel Odeke <emmanuel@orijtech.com> Run-TryBot: Emmanuel Odeke <emmanuel@orijtech.com> TryBot-Result: Go Bot <gobot@golang.org>
2020-08-18all: fix spelling mistakeslihaowei
Change-Id: I7d512281d8442d306594b57b5deaecd132b5ea9e GitHub-Last-Rev: 251e1d6857516b21fd71f654133f81f23ffec654 GitHub-Pull-Request: golang/go#40793 Reviewed-on: https://go-review.googlesource.com/c/go/+/248441 Reviewed-by: Dave Cheney <dave@cheney.net>
2020-04-28bufio: optimize bufio.Reader.ReadString to avoid an allocation and copyAlex Gaynor
name old time/op new time/op delta ReaderReadString-4 226ns ±12% 161ns ±11% -28.76% (p=0.008 n=5+5) name old alloc/op new alloc/op delta ReaderReadString-4 288B ± 0% 144B ± 0% -50.00% (p=0.008 n=5+5) name old allocs/op new allocs/op delta ReaderReadString-4 2.00 ± 0% 1.00 ± 0% -50.00% (p=0.008 n=5+5) Change-Id: I77f330b8340c2bfbfff1f6f1000170b65953a200 GitHub-Last-Rev: 65d65302a7b80504b4d37b81a3843fe1439e638a GitHub-Pull-Request: golang/go#34706 Reviewed-on: https://go-review.googlesource.com/c/go/+/199257 Run-TryBot: Ian Lance Taylor <iant@golang.org> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Ian Lance Taylor <iant@golang.org>
2019-10-31bufio: return the underlying error in ReadFrom if not nilCuong Manh Le
If a previous Write returned an error, any subsequent Write or ReadFrom must return that error before any operations. However, only Write behaved correctly and this change fixes that problem by making sure that ReadFrom firstly checks for the underlying error. Fixes #35194 Change-Id: I31356a9e8bd945bc0168b2e3be470f3ae69d4813 Reviewed-on: https://go-review.googlesource.com/c/go/+/204000 Run-TryBot: Cuong Manh Le <cuong.manhle.vn@gmail.com> Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org> Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org> Reviewed-by: Emmanuel Odeke <emm.odeke@gmail.com> Reviewed-by: Ian Lance Taylor <iant@golang.org> TryBot-Result: Gobot Gobot <gobot@golang.org>
2019-10-31bufio: save error from underlying ReadFromCuong Manh Le
Updates #35194 Change-Id: Ib854bc6250ddeb606d6ff6240179e23b98e4ac62 Reviewed-on: https://go-review.googlesource.com/c/go/+/203999 Run-TryBot: Cuong Manh Le <cuong.manhle.vn@gmail.com> Reviewed-by: Ian Lance Taylor <iant@golang.org> Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org> TryBot-Result: Gobot Gobot <gobot@golang.org>
2019-10-04bufio: simplify bufio.Reader.ReadBytes to avoid an extra loop over a sliceAlex Gaynor
Change-Id: Icb1c3eb30147180ba5949a25c65b48307b14c1ca GitHub-Last-Rev: 937ae8641321139b9165ce7d57abeac5a67dc24d GitHub-Pull-Request: golang/go#34704 Reviewed-on: https://go-review.googlesource.com/c/go/+/199157 Run-TryBot: Ian Lance Taylor <iant@golang.org> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Ian Lance Taylor <iant@golang.org>
2019-06-20bufio: Reader.Read may return io.EOF even when it has data bufferedDaniel Cormier
If reading 0 bytes, don't return the error from the underlying io.Reader if there is still data buffered. Fixes #32693 Change-Id: I12a97bd6003c638c15d41028942f27edf88340e2 Reviewed-on: https://go-review.googlesource.com/c/go/+/182997 Run-TryBot: Robert Griesemer <gri@golang.org> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Robert Griesemer <gri@golang.org>
2019-01-08bufio: document relationship between UnreadByte/UnreadRune and PeekBrad Fitzpatrick
Fixes #29387 Change-Id: I2d9981f63ac16630ed39d6da6692c81396f4e9ea Reviewed-on: https://go-review.googlesource.com/c/155930 Reviewed-by: Ian Lance Taylor <iant@golang.org>
2018-11-13bufio: make Reader.Peek invalidate UnreadsMartin Garton
Since Reader.Peek potentially reads from the underlying io.Reader, discarding previous buffers, UnreadRune and UnreadByte cannot necessarily work. Change Peek to invalidate the unread buffers in all cases (as allowed according to the documentation) and thus prevent hiding bugs in the caller. (This change was previoiusly merged and then reverted due concern about being too close to a release) Fixes #18556 Change-Id: I9027d75aa834d4b27703f37711ba25de04d89f3c GitHub-Last-Rev: 917ef1e51131d734f92efc946a0ab5ca4ff69be6 GitHub-Pull-Request: golang/go#28768 Reviewed-on: https://go-review.googlesource.com/c/149297 Run-TryBot: Ian Lance Taylor <iant@golang.org> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Ian Lance Taylor <iant@golang.org>
2018-11-13bufio: put notes about len(p) togetherRuss Cox
CL 145577 added the part about io.ReadFull to read len(p) but it should be next to the existing sentence about not reading len(p) bytes. Change-Id: Idfa037c59a3085d44d5da6129188473db0e96d23 Reviewed-on: https://go-review.googlesource.com/c/148903 Run-TryBot: Russ Cox <rsc@golang.org> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org> Reviewed-by: Alan Donovan <adonovan@google.com>
2018-10-30bufio: suggest io.ReadFull at (*Reader).ReadAlan Donovan
Many times when using bufio.Reader I imagine, incorrectly, that it implements the retry loop itself, being a high-level buffered wrapper around, say, a file descriptor prone to short reads. This comment would have saved me much time. Change-Id: I34c790e0d7c1515430a76d02ce4739b586a36ba7 Reviewed-on: https://go-review.googlesource.com/c/145577 Reviewed-by: Ian Lance Taylor <iant@golang.org> Reviewed-by: Rob Pike <r@golang.org>
2018-08-22bufio: avoid rescanning buffer multiple times in ReadSliceandrius4669
When existing data in buffer does not have delimiter, and new data is added with b.fill(), continue search from previous point instead of starting from beginning. Change-Id: Id78332afe2b0281b4a3c86bd1ffe9449cfea7848 GitHub-Last-Rev: 08e7d2f50151a00b22800e3f7020d0de8dee7dcf GitHub-Pull-Request: golang/go#25441 Reviewed-on: https://go-review.googlesource.com/113535 Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Ian Lance Taylor <iant@golang.org>
2018-08-20bufio: make Reader naming consistentnogoegst
All the readers are denoted as `b` while for `Reader.Size()` it is `r`. Change-Id: Ib6f97306c11b3abb2ff30edbc9f9362cad36d080 GitHub-Last-Rev: 992f88b374b5a309303b7fa1622ee629d0fb741b GitHub-Pull-Request: golang/go#26205 Reviewed-on: https://go-review.googlesource.com/122156 Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2018-03-28bufio: document ReadFrom/WriteTo calls to underlying methodsIan Lance Taylor
In general use of these magic methods must be documented so that users understand what will happen. Fixes #23289 Change-Id: Ic46915eee1d3b7e57d8d1886834ddfb2e8e66e62 Reviewed-on: https://go-review.googlesource.com/103238 Reviewed-by: Rob Pike <r@golang.org>
2017-11-02bufio: add Reader.Size and Writer.Size accessorsBrad Fitzpatrick
Fixes #21343 Change-Id: I3582fced902592fe12bfa29acf7b40b6e5e554a7 Reviewed-on: https://go-review.googlesource.com/75150 Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Robert Griesemer <gri@golang.org>
2017-07-06Revert "bufio: make Reader.Peek invalidate Unreads"Russ Cox
Go 1.9 beta 2 is already out. It's too late to break code with a change like this. This can be rolled forward for Go 1.10. This reverts commit ae238688d2813e83f16050408487ea34ba1c2fff. Change-Id: Ib67b8629e3deac5d50d76581aba6a91ca7a7853e Reviewed-on: https://go-review.googlesource.com/47570 Reviewed-by: Russ Cox <rsc@golang.org>
2017-06-27bufio: make Reader.Peek invalidate UnreadsMartin Garton
Since Reader.Peek potentially reads from the underlying io.Reader, discarding previous buffers, UnreadRune and UnreadByte cannot necessarily work. Change Peek to invalidate the unread buffers in all cases (as allowed according to the documentation) and thus prevent hiding bugs in the caller. Fixes #18556 Change-Id: I8d836db7ce31c4aaecb4f61c24573b0332bbf30d Reviewed-on: https://go-review.googlesource.com/46850 Reviewed-by: Robert Griesemer <gri@golang.org>
2017-06-09all: single space after periodBrad Fitzpatrick
Done with grep & interactive search & replace, to double-check replacements. Not many remained after CL 20022. Fixes #18572 Change-Id: Idbe90ba3b584f9b9661d2bbd141607daaadfa41a Reviewed-on: https://go-review.googlesource.com/45270 Reviewed-by: Joe Tsai <thebrokentoaster@gmail.com>
2017-06-08bufio: clarify WriteTo docsSam Whited
Fixes #19092 Change-Id: I7c0fde6a4cf460017619dbcce1c1ddaa7af1022a Reviewed-on: https://go-review.googlesource.com/44811 Reviewed-by: Ian Lance Taylor <iant@golang.org>
2017-04-21bufio: clarify that Flush returns a cached write errorIan Lance Taylor
Change-Id: I377403fc0981d58aec5d84a1dd0d4e08532a575c Reviewed-on: https://go-review.googlesource.com/41291 Reviewed-by: Dan Peterson <dpiddy@gmail.com> Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2016-10-18bufio: read from underlying reader at most once in ReadRuss Cox
Fixes #17059. Change-Id: I5c7ee46604399f7dc3c3c49f964cbb1aa6c0d621 Reviewed-on: https://go-review.googlesource.com/31320 Reviewed-by: Ian Lance Taylor <iant@golang.org>
2016-10-01bufio: remove redundant Writer.flush methodMatt Layher
Fixes #17232 Change-Id: I34df86f79b643dce9f054c6df6782e6037c06910 Reviewed-on: https://go-review.googlesource.com/30158 Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2016-04-10all: replace magic 0x80 with named constant utf8.RuneSelfMartin Möhrmann
Change-Id: Id1c2e8e9d60588de866e8b6ca59cc83dd28f848f Reviewed-on: https://go-review.googlesource.com/21756 Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org> Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org> TryBot-Result: Gobot Gobot <gobot@golang.org>
2016-03-04bufio: Reader.Peek returns partial results on ErrBufferFulldjherbis
The existing implementation returns nil, ErrBufferFull when n > len(b.buf), now it will return any data in the buffer and ErrBufferFull. Fixes #14121 Change-Id: Ie52d32ccd80e4078ebfae6e75393c89675959ead Reviewed-on: https://go-review.googlesource.com/19091 Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Robert Griesemer <gri@golang.org>
2016-03-02all: single space after period.Brad Fitzpatrick
The tree's pretty inconsistent about single space vs double space after a period in documentation. Make it consistently a single space, per earlier decisions. This means contributors won't be confused by misleading precedence. This CL doesn't use go/doc to parse. It only addresses // comments. It was generated with: $ perl -i -npe 's,^(\s*// .+[a-z]\.) +([A-Z]),$1 $2,' $(git grep -l -E '^\s*//(.+\.) +([A-Z])') $ go test go/doc -update Change-Id: Iccdb99c37c797ef1f804a94b22ba5ee4b500c4f7 Reviewed-on: https://go-review.googlesource.com/20022 Reviewed-by: Rob Pike <r@golang.org> Reviewed-by: Dave Day <djd@golang.org> Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org> TryBot-Result: Gobot Gobot <gobot@golang.org>
2016-02-29all: remove public named return values when uselessBrad Fitzpatrick
Named returned values should only be used on public funcs and methods when it contributes to the documentation. Named return values should not be used if they're only saving the programmer a few lines of code inside the body of the function, especially if that means there's stutter in the documentation or it was only there so the programmer could use a naked return statement. (Naked returns should not be used except in very small functions) This change is a manual audit & cleanup of public func signatures. Signatures were not changed if: * the func was private (wouldn't be in public godoc) * the documentation referenced it * the named return value was an interesting name. (i.e. it wasn't simply stutter, repeating the name of the type) There should be no changes in behavior. (At least: none intended) Change-Id: I3472ef49619678fe786e5e0994bdf2d9de76d109 Reviewed-on: https://go-review.googlesource.com/20024 Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Andrew Gerrand <adg@golang.org>
2016-02-24all: fix typos and spellingMartin Möhrmann
Change-Id: Icd06d99c42b8299fd931c7da821e1f418684d913 Reviewed-on: https://go-review.googlesource.com/19829 Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org> Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org> TryBot-Result: Gobot Gobot <gobot@golang.org>
2015-12-01bufio: clarify Read docsRuss Cox
Or at least make them true. Fixes #12237. Change-Id: I3c92a07233b2174c5731d6fa7fbb9ca3a97beb6b Reviewed-on: https://go-review.googlesource.com/17237 Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2015-07-18bufio: Remove unneeded error initializationSilvan Jegen
The default value for error is nil so there is no need to assign this value here. Change-Id: I4714ef7607996ccbf91b704390e1d1d39ee3847b Reviewed-on: https://go-review.googlesource.com/12355 Reviewed-by: Ian Lance Taylor <iant@golang.org> Run-TryBot: Ian Lance Taylor <iant@golang.org> TryBot-Result: Gobot Gobot <gobot@golang.org>
2015-01-07bufio: add Reader.DiscardBrad Fitzpatrick
Reader.Discard is the complement to Peek. It discards the next n bytes of input. We already have Reader.Buffered to see how many bytes of data are sitting available in memory, and Reader.Peek to get that that buffer directly. But once you're done with the Peek'd data, you can't get rid of it, other than Reading it. Both Read and io.CopyN(ioutil.Discard, bufReader, N) are relatively slow. People instead resort to multiple blind ReadByte calls, just to advance the internal b.r variable. I've wanted this previously, several people have asked for it in the past on golang-nuts/dev, and somebody just asked me for it again in a private email. There are a few places in the standard library we'd use it too. Change-Id: I85dfad47704a58bd42f6867adbc9e4e1792bc3b0 Reviewed-on: https://go-review.googlesource.com/2260 Reviewed-by: Russ Cox <rsc@golang.org>
2014-09-08build: move package sources from src/pkg to srcRuss Cox
Preparation was in CL 134570043. This CL contains only the effect of 'hg mv src/pkg/* src'. For more about the move, see golang.org/s/go14nopkg.