aboutsummaryrefslogtreecommitdiff
path: root/src/io/example_test.go
AgeCommit message (Collapse)Author
2022-09-06io: use strings.Buildercuiweixie
Change-Id: Ibab20627ccd1f79e77e3972e2bc6ca42c2c7de13 Reviewed-on: https://go-review.googlesource.com/c/go/+/428263 TryBot-Result: Gopher Robot <gobot@golang.org> Auto-Submit: Ian Lance Taylor <iant@google.com> Run-TryBot: Ian Lance Taylor <iant@google.com> Reviewed-by: Robert Griesemer <gri@google.com> Reviewed-by: Ian Lance Taylor <iant@google.com>
2022-06-04io: revert: add an Err field to LimitedReaderRuss Cox
We are having a hard time deciding the exact semantics of the Err field, and we need to ship the beta. So revert the Err field change; it can wait for Go 1.20. For #51115. This reverts CL 396215. Change-Id: I7719386567d3da10a614058a11f19dbccf304b4d Reviewed-on: https://go-review.googlesource.com/c/go/+/410133 TryBot-Result: Gopher Robot <gobot@golang.org> Reviewed-by: Ian Lance Taylor <iant@golang.org> Reviewed-by: Dmitri Shuralyov <dmitshur@google.com> Reviewed-by: Dmitri Shuralyov <dmitshur@golang.org> Run-TryBot: Russ Cox <rsc@golang.org> Reviewed-by: Bryan Mills <bcmills@google.com> Auto-Submit: Russ Cox <rsc@golang.org>
2022-05-04io: add an Err field to LimitedReaderCarl Johnson
Fixes #51115 Change-Id: I3c5296e4adc71c1c1b1808a45abd4801ae43465a GitHub-Last-Rev: 4c197acd51e1cac051302deba57b97da66e004e1 GitHub-Pull-Request: golang/go#51990 Reviewed-on: https://go-review.googlesource.com/c/go/+/396215 Reviewed-by: Dmitri Shuralyov <dmitshur@google.com> TryBot-Result: Gopher Robot <gobot@golang.org> Run-TryBot: Ian Lance Taylor <iant@google.com> Run-TryBot: Ian Lance Taylor <iant@golang.org> Auto-Submit: Ian Lance Taylor <iant@google.com> Reviewed-by: Ian Lance Taylor <iant@google.com>
2021-11-11io: add error check to TeeReader Examplejiahua wang
Change-Id: I0b94bdced47483c6412e9979ce2d103fbfc52afb Reviewed-on: https://go-review.googlesource.com/c/go/+/353729 Run-TryBot: Ian Lance Taylor <iant@golang.org> TryBot-Result: Go Bot <gobot@golang.org> Reviewed-by: Ian Lance Taylor <iant@golang.org> Trust: Carlos Amedee <carlos@golang.org>
2021-09-28io: add examples for (*SectionReader) Read/Sizejiahua wang
Change-Id: Ie804f9a5d1d6beec210d2f8075c030a5c60a78ea Reviewed-on: https://go-review.googlesource.com/c/go/+/352152 Run-TryBot: Ian Lance Taylor <iant@golang.org> TryBot-Result: Go Bot <gobot@golang.org> Reviewed-by: Ian Lance Taylor <iant@golang.org> Trust: Heschi Kreinick <heschi@google.com>
2021-03-13io: add error check to WriteString Example testJulianChu
Change-Id: I9ce1c79e5799f205aec3a4dc02645ed26bdc3581 GitHub-Last-Rev: 59b637db0154e55ddfdd55e54b9596dc3a0ad32d GitHub-Pull-Request: golang/go#44533 Reviewed-on: https://go-review.googlesource.com/c/go/+/295389 Reviewed-by: Emmanuel Odeke <emmanuel@orijtech.com> Reviewed-by: Robert Griesemer <gri@golang.org> Trust: Emmanuel Odeke <emmanuel@orijtech.com> Trust: Robert Griesemer <gri@golang.org> Run-TryBot: Emmanuel Odeke <emmanuel@orijtech.com> TryBot-Result: Go Bot <gobot@golang.org>
2020-10-20all: update references to symbols moved from io/ioutil to ioRuss Cox
The old ioutil references are still valid, but update our code to reflect best practices and get used to the new locations. Code compiled with the bootstrap toolchain (cmd/asm, cmd/dist, cmd/compile, debug/elf) must remain Go 1.4-compatible and is excluded. Also excluded vendored code. For #41190. Change-Id: I6d86f2bf7bc37a9d904b6cee3fe0c7af6d94d5b1 Reviewed-on: https://go-review.googlesource.com/c/go/+/263142 Trust: Russ Cox <rsc@golang.org> Run-TryBot: Russ Cox <rsc@golang.org> TryBot-Result: Go Bot <gobot@golang.org> Reviewed-by: Emmanuel Odeke <emm.odeke@gmail.com>
2020-10-20io: adopt Discard, NopCloser, ReadAll from io/ioutilRuss Cox
As proposed and approved in #40025, Discard, NopCloser, and ReadAll do not really fit into io/ioutil, which exists mainly to hold things that would cause an import cycle if implemented in io itself, which is to say things that import "os". These three do not import "os" - they are generic io helpers like many of the things in io itself, so it makes sense for them to be there. Fixes #40025. Change-Id: I77f47e9b2a72839edf7446997936631980047b67 Reviewed-on: https://go-review.googlesource.com/c/go/+/263141 Trust: Russ Cox <rsc@golang.org> Run-TryBot: Russ Cox <rsc@golang.org> TryBot-Result: Go Bot <gobot@golang.org> Reviewed-by: Rob Pike <r@golang.org>
2020-04-13io: simplify ExamplesEric
- CopyN: 5 creates ambiguity with respect to whitespace and upperbound - TeeReader less boilerplate and displays a common usage of it - SectionReader_* all sections unified to 5:17 for clarity - SectionReader_Seek uses io.Copy to stdout like other examples - Seeker_Seek remove useless prints - Pipe print reader like other examples Updates #36417 Change-Id: Ibd01761d5a5786cdb1ea934f7a98f8302430c8a5 GitHub-Last-Rev: 4c17f9a8e32d89743b7eaec7c52032256972cc0a GitHub-Pull-Request: golang/go#38379 Reviewed-on: https://go-review.googlesource.com/c/go/+/227868 Run-TryBot: Ian Lance Taylor <iant@golang.org> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Ian Lance Taylor <iant@golang.org>
2019-12-27io: show ErrUnexpectedEOF in ExampleReadAtLeastIan Lance Taylor
Fixes #36245 Change-Id: I10ce50b0cc28b15f4e7be85b8f12cf9d0e4fac96 Reviewed-on: https://go-review.googlesource.com/c/go/+/212404 Run-TryBot: Ian Lance Taylor <iant@golang.org> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Emmanuel Odeke <emm.odeke@gmail.com>
2017-08-22io: add example for PipeGuilherme Rezende
Change-Id: I24374accf48d43edf4bf27ea6ba2245ddca558ad Reviewed-on: https://go-review.googlesource.com/50910 Reviewed-by: Giovanni Bajo <rasky@develer.com> Reviewed-by: Joe Tsai <thebrokentoaster@gmail.com> Run-TryBot: Joe Tsai <thebrokentoaster@gmail.com> TryBot-Result: Gobot Gobot <gobot@golang.org>
2017-07-15io: Add example to io.Seeker's Seek() method.Greg Poirier
While there's an example for SectionReader.Seek, if someone is seeking documentation specifically about Seeker.Seek, they may not immediately find the SectionReader example. Offset and whence may not be entirely intuitive to new developers either, so include examples of both positive/negative offsets and SeekStart/SeekEnd. Change-Id: I5b7442ccf683d9706e9261c11bc0ea31a1ac21d4 Reviewed-on: https://go-review.googlesource.com/48873 Reviewed-by: Kevin Burke <kev@inburke.com> Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org> Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org> TryBot-Result: Gobot Gobot <gobot@golang.org>
2016-05-06all: use SeekStart, SeekCurrent, SeekEndJoe Tsai
CL/19862 (f79b50b8d5bc159561c1dcf7c17e2a0db96a9a11) recently introduced the constants SeekStart, SeekCurrent, and SeekEnd to the io package. We should use these constants consistently throughout the code base. Updates #15269 Change-Id: If7fcaca7676e4a51f588528f5ced28220d9639a2 Reviewed-on: https://go-review.googlesource.com/22097 Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org> Run-TryBot: Joe Tsai <joetsai@digital-static.net> TryBot-Result: Gobot Gobot <gobot@golang.org>
2015-11-30io: add examples to functionsCarlos C
Change-Id: Id72cf4daceb7669cf9c7247df8e3ba086ccfe96e Reviewed-on: https://go-review.googlesource.com/12730 Reviewed-by: Russ Cox <rsc@golang.org>