aboutsummaryrefslogtreecommitdiff
path: root/src/io
AgeCommit message (Collapse)Author
2023-02-14Revert "io: detect Writers that access io.Copy's buffer after returning"Damien Neil
This reverts CL 466865. Reason for revert: Causing trybot flakiness due to net/http race, roll back until net/http is fixed. For #58168 Change-Id: I3129deb996abe6466eccf933fe93cbbaf72ae217 Reviewed-on: https://go-review.googlesource.com/c/go/+/467895 TryBot-Result: Gopher Robot <gobot@golang.org> Auto-Submit: Damien Neil <dneil@google.com> Reviewed-by: Bryan Mills <bcmills@google.com> Run-TryBot: Damien Neil <dneil@google.com>
2023-02-10io: detect Writers that access io.Copy's buffer after returningDamien Neil
When the race detector is enabled, scribble over copy buffers with garbage after Write returns. For #58452 Change-Id: I25547684bcbef7d302d76736cb02e59c89a640ee Reviewed-on: https://go-review.googlesource.com/c/go/+/466865 Reviewed-by: Bryan Mills <bcmills@google.com> Run-TryBot: Damien Neil <dneil@google.com> TryBot-Result: Gopher Robot <gobot@golang.org> Auto-Submit: Damien Neil <dneil@google.com>
2023-02-10Revert "io: allocate copy buffers from a pool"Damien Neil
This reverts CL 456555. Reason for revert: This seems too likely to exercise race conditions in code where a Write call continues to access its buffer after returning. The HTTP/2 ResponseWriter is one such example. Reverting this change while we think about this some more. For #57202 Change-Id: Ic86823f81d7da410ea6b3f17fb5b3f9a979e3340 Reviewed-on: https://go-review.googlesource.com/c/go/+/467095 Reviewed-by: Bryan Mills <bcmills@google.com> Run-TryBot: Damien Neil <dneil@google.com> TryBot-Result: Gopher Robot <gobot@golang.org>
2023-01-31io: allocate copy buffers from a poolDamien Neil
CopyBuffer allocates a 32k buffer when no buffer is available. Allocate these buffers from a sync.Pool. This removes an optimization where the copy buffer size was reduced when the source is a io.LimitedReader (including the case of CopyN) with a limit less than the default buffer size. This change could cause a program which only uses io.Copy with sources with a small limit to allocate unnecessarily large buffers. Programs which care about the transient buffer allocation can avoid this by providing their own buffer. name old time/op new time/op delta CopyNSmall-10 165ns ± 7% 117ns ± 7% -29.19% (p=0.001 n=7+7) CopyNLarge-10 7.33µs ±34% 4.07µs ± 2% -44.52% (p=0.001 n=7+7) name old alloc/op new alloc/op delta CopyNSmall-10 2.20kB ±12% 1.20kB ± 4% -45.24% (p=0.000 n=8+7) CopyNLarge-10 148kB ± 9% 81kB ± 4% -45.26% (p=0.000 n=8+7) name old allocs/op new allocs/op delta CopyNSmall-10 2.00 ± 0% 1.00 ± 0% -50.00% (p=0.000 n=8+8) CopyNLarge-10 2.00 ± 0% 1.00 ± 0% -50.00% (p=0.000 n=8+8) For #57202 Change-Id: I2292226da9ba1dc09a2543f5d74fe5da06080d49 Reviewed-on: https://go-review.googlesource.com/c/go/+/456555 TryBot-Result: Gopher Robot <gobot@golang.org> Run-TryBot: Damien Neil <dneil@google.com> Reviewed-by: Thomas Austad <thomas.austad@gmail.com> Auto-Submit: Damien Neil <dneil@google.com> Reviewed-by: Ian Lance Taylor <iant@google.com>
2022-11-18io/fs: clean up test helper functionsTobias Klauser
Inline the only use of checkMarks which also allows to drop the always-true report argument. This also ensures the correct line gets reported in case of an error. Also remove the unused markTree function and drop the unused testing.T argument from makeTree. Change-Id: I4033d3e5ecd929d08ce03c563aa99444e102d931 Reviewed-on: https://go-review.googlesource.com/c/go/+/451615 Reviewed-by: Joedian Reid <joedian@golang.org> Reviewed-by: Ian Lance Taylor <iant@google.com> Auto-Submit: Tobias Klauser <tobias.klauser@gmail.com> Run-TryBot: Tobias Klauser <tobias.klauser@gmail.com> TryBot-Result: Gopher Robot <gobot@golang.org>
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-08-25path/filepath, io/fs: add SkipAllPaschalis Tsilias
Fixes #47209 Change-Id: If75b0dd38f2c30a23517205d80c7a6683a5c921c Reviewed-on: https://go-review.googlesource.com/c/go/+/363814 TryBot-Result: Gopher Robot <gobot@golang.org> Reviewed-by: Ian Lance Taylor <iant@google.com> Auto-Submit: Ian Lance Taylor <iant@google.com> Reviewed-by: Daniel Martí <mvdan@mvdan.cc> Run-TryBot: Daniel Martí <mvdan@mvdan.cc> Reviewed-by: Bryan Mills <bcmills@google.com>
2022-08-19io: add OffsetWriter, NewOffsetWriterhopehook
Offsetwriter refers to the design of SectionReader and removes the section parameter n. Since the size of the written data is determined by the user, we cannot know where the end offset of the original data is. The offset of SeekEnd is not valid in Seek method. Fixes #45899. Change-Id: I9d9445aecfa0dd4fc5168f2f65e1e3055c201b45 Reviewed-on: https://go-review.googlesource.com/c/go/+/406776 Run-TryBot: Ian Lance Taylor <iant@google.com> Reviewed-by: Joedian Reid <joedian@golang.org> Reviewed-by: Ian Lance Taylor <iant@google.com> TryBot-Result: Gopher Robot <gobot@golang.org> Run-TryBot: Ian Lance Taylor <iant@golang.org> Auto-Submit: Ian Lance Taylor <iant@google.com>
2022-07-12io/fs: fix stack exhaustion in GlobJulie Qiu
A limit is added to the number of path separators allowed by an input to Glob, to prevent stack exhaustion issues. Thanks to Juho Nurminen of Mattermost who reported a similar issue in path/filepath. Fixes CVE-2022-30630 Fixes golang/go#53415 Change-Id: I5a9d02591fed90cd3d52627f5945f1301e53465d Reviewed-on: https://team-review.git.corp.google.com/c/golang/go-private/+/1497588 Reviewed-by: Roland Shoemaker <bracewell@google.com> Reviewed-on: https://go-review.googlesource.com/c/go/+/417065 Run-TryBot: Michael Knyszek <mknyszek@google.com> TryBot-Result: Gopher Robot <gobot@golang.org> Reviewed-by: Heschi Kreinick <heschi@google.com>
2022-06-25io: clarify SeekEnd offset valueHowJMay
fixes #53474 Change-Id: I14c3dc800dc27233630a54592328bb0df1bbaa5d GitHub-Last-Rev: 46f93cfbd41c1b3274b570744f18d08e7759eb1e GitHub-Pull-Request: golang/go#53505 Reviewed-on: https://go-review.googlesource.com/c/go/+/413614 Reviewed-by: Ian Lance Taylor <iant@google.com> Reviewed-by: Emmanuel Odeke <emmanuel@orijtech.com> Reviewed-by: Dmitri Shuralyov <dmitshur@google.com> TryBot-Result: Gopher Robot <gobot@golang.org> Auto-Submit: Emmanuel Odeke <emmanuel@orijtech.com> Run-TryBot: Ian Lance Taylor <iant@google.com> Auto-Submit: 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-19all: gofmt main repoRuss Cox
Excluding vendor and testdata. CL 384268 already reformatted most, but these slipped past. The struct in the doc comment in debug/dwarf/type.go was fixed up by hand to indent the first and last lines as well. For #51082. Change-Id: Iad020f83aafd671ff58238fe491907e85923d0c7 Reviewed-on: https://go-review.googlesource.com/c/go/+/407137 Run-TryBot: Russ Cox <rsc@golang.org> TryBot-Result: Gopher Robot <gobot@golang.org> Auto-Submit: Russ Cox <rsc@golang.org> Reviewed-by: Ian Lance Taylor <iant@google.com>
2022-05-18all: fix spellingJohn Bampton
Change-Id: I63eb42f3ce5ca452279120a5b33518f4ce16be45 GitHub-Last-Rev: a88f2f72bef402344582ae997a4907457002b5df GitHub-Pull-Request: golang/go#52951 Reviewed-on: https://go-review.googlesource.com/c/go/+/406843 Run-TryBot: Robert Griesemer <gri@google.com> TryBot-Result: Gopher Robot <gobot@golang.org> Run-TryBot: Ian Lance Taylor <iant@google.com> Reviewed-by: Ian Lance Taylor <iant@google.com> Reviewed-by: Robert Griesemer <gri@google.com> Auto-Submit: Ian Lance Taylor <iant@google.com>
2022-05-17io/fs: document requirement that ReadDir return an unwrapped io.EOFDamien Neil
This requirement ensures that ReadDir implementations are as compatible as possible with "*os.File".ReadDir. The testing/fstest package already tests for equality to io.EOF. Updates #47062. Fixes #47086. Change-Id: I54f911a34e507a3db0abc4da55a19b7a50b35041 Reviewed-on: https://go-review.googlesource.com/c/go/+/333149 Reviewed-by: Michael Knyszek <mknyszek@google.com>
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>
2022-05-03io: NopCloser forward WriterTo implementations if the reader supports itJorropo
This patch also include related fixes to net/http. io_test.go don't test reading or WritingTo of the because the logic is simple. NopCloser didn't even had direct tests before. Fixes #51566 Change-Id: I1943ee2c20d0fe749f4d04177342ce6eca443efe GitHub-Last-Rev: a6b9af4e945a6903735a74aa185e2d1c4c2e2cef GitHub-Pull-Request: golang/go#52340 Reviewed-on: https://go-review.googlesource.com/c/go/+/400236 Run-TryBot: Ian Lance Taylor <iant@golang.org> Run-TryBot: Ian Lance Taylor <iant@google.com> TryBot-Result: Gopher Robot <gobot@golang.org> Reviewed-by: Ian Lance Taylor <iant@google.com> Reviewed-by: Benny Siegert <bsiegert@gmail.com> Auto-Submit: Ian Lance Taylor <iant@google.com>
2022-04-19io/ioutil: provide an equivalent for the deprecated ReadDirDaniel Martí
All APIs in the now-deprecated io/ioutil package have a direct replacement in either the io or os package with the same signature, with the notable exception of ioutil.ReadDir, as os.ReadDir has a slightly different signature with fs.DirEntry rather than fs.FileInfo. New code can easily make use of []fs.DirEntry directly, but existing code may need to continue using []fs.FileInfo for backwards compatibility reasons. For instance, I had a bit of code that exposed the slice as a public API, like: return ioutil.ReadDir(name) It took me a couple of minutes to figure out what the exact equivalent in terms of os.ReadDir would be, and a code sample would have helped. Add one for future reference. For #42026. For #51927. Change-Id: I76d46cd7d68fc609c873821755fdcfc299ffd56c Reviewed-on: https://go-review.googlesource.com/c/go/+/399854 Reviewed-by: Bryan Mills <bcmills@google.com> Run-TryBot: Bryan Mills <bcmills@google.com> TryBot-Result: Gopher Robot <gobot@golang.org> Reviewed-by: Ian Lance Taylor <iant@google.com> Run-TryBot: Ian Lance Taylor <iant@google.com> Auto-Submit: Ian Lance Taylor <iant@google.com>
2022-04-01all: remove trailing blank doc comment linesRuss Cox
A future change to gofmt will rewrite // Doc comment. // func f() to // Doc comment. func f() Apply that change preemptively to all doc comments. For #51082. Change-Id: I4023e16cfb0729b64a8590f071cd92f17343081d Reviewed-on: https://go-review.googlesource.com/c/go/+/384259 Trust: Russ Cox <rsc@golang.org> Run-TryBot: Russ Cox <rsc@golang.org> Reviewed-by: Ian Lance Taylor <iant@golang.org> TryBot-Result: Gopher Robot <gobot@golang.org>
2022-03-28io/fs, path/filepath: honor SkipDir on second WalkDirFunc error callIan Lance Taylor
Fixes #51617 Change-Id: I03e9e575d9bad1481e7e4f051b50a077ba5f2fe0 Reviewed-on: https://go-review.googlesource.com/c/go/+/392154 Trust: Ian Lance Taylor <iant@golang.org> Run-TryBot: Ian Lance Taylor <iant@golang.org> TryBot-Result: Gopher Robot <gobot@golang.org> Reviewed-by: Emmanuel Odeke <emmanuel@orijtech.com>
2022-03-28io/ioutil: add deprecation markers to ioutilJeff Widman
All the code in ioutil just forwards functionality to code in either the io or os packages, per issue 42026. This change adds the "Deprecated" marker to all the functions in this package. For #42026 Fixes #51927 Change-Id: Ia807bc5c0edb06cc80ec7e35917dcfe2ad50f0ea GitHub-Last-Rev: 3c3603f368e2be517cdd946ae6a666d4e1eda67a GitHub-Pull-Request: golang/go#51961 Reviewed-on: https://go-review.googlesource.com/c/go/+/395918 Reviewed-by: Emmanuel Odeke <emmanuel@orijtech.com> Trust: Emmanuel Odeke <emmanuel@orijtech.com> Run-TryBot: Emmanuel Odeke <emmanuel@orijtech.com> TryBot-Result: Gopher Robot <gobot@golang.org> Reviewed-by: Ian Lance Taylor <iant@golang.org>
2022-03-07io: add WriterTo to MultiReaderJorropo
This patch allows to zerocopy using MultiReader. This is done by MultiReader implementing WriterTo. Each sub reader is copied using usual io copy helper and thus use WriterTo or ReadFrom with reflection. There is a special case for when a subreader is a MultiReader. Instead of using copyBuffer which would call multiReader.WriteTo, multiReader.writeToWithBuffer is used instead, the difference is that the temporary copy buffer is passed along, saving allocations for nested MultiReaders. The workflow looks like this: - multiReader.WriteTo (allocates 32k buffer) - multiReader.writeToWithBuffer - for each subReader: - is instance of multiReader ? - yes, call multiReader.writeToWithBuffer - no, call copyBuffer(writer, currentReader, buffer) - does currentReader implements WriterTo ? - yes, use use currentReader.WriteTo - no, does writer implement ReadFrom ? - yes, use writer.ReadFrom - no, copy using Read / Write with buffer This can be improved by lazy allocating the 32k buffer. For example a MultiReader of such types: MultiReader( bytes.Reader, // WriterTo-able bytes.Reader, // WriterTo-able bytes.Reader, // WriterTo-able ) Doesn't need any allocation, all copy can be done using bytes.Reader's internal data slice. However currently we still allocate a 32k buffer for nothing. This optimisation has been omitted for a future patch because of high complexity costs for a non obvious performance cost (it needs a benchmark). This patch at least is on par with the previous MultiReader.Read workflow allocation wise. Fixes #50842 Change-Id: Ib070c8f36337d9dd86090df8a703c5df97a773ae GitHub-Last-Rev: 8ebe60ceacec6bd52b63d9bdc05cd5b4ada57a6e GitHub-Pull-Request: golang/go#51502 Reviewed-on: https://go-review.googlesource.com/c/go/+/390215 Run-TryBot: Ian Lance Taylor <iant@golang.org> TryBot-Result: Gopher Robot <gobot@golang.org> Reviewed-by: Ian Lance Taylor <iant@golang.org> Reviewed-by: Daniel Martí <mvdan@mvdan.cc> Trust: Daniel Martí <mvdan@mvdan.cc>
2021-12-13all: gofmt -w -r 'interface{} -> any' srcRuss Cox
And then revert the bootstrap cmd directories and certain testdata. And adjust tests as needed. Not reverting the changes in std that are bootstrapped, because some of those changes would appear in API docs, and we want to use any consistently. Instead, rewrite 'any' to 'interface{}' in cmd/dist for those directories when preparing the bootstrap copy. A few files changed as a result of running gofmt -w not because of interface{} -> any but because they hadn't been updated for the new //go:build lines. Fixes #49884. Change-Id: Ie8045cba995f65bd79c694ec77a1b3d1fe01bb09 Reviewed-on: https://go-review.googlesource.com/c/go/+/368254 Trust: Russ Cox <rsc@golang.org> Run-TryBot: Russ Cox <rsc@golang.org> Reviewed-by: Robert Griesemer <gri@golang.org> TryBot-Result: Gopher Robot <gobot@golang.org>
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-10-29io: remove UTF8 specified document for RuneReaderMeng Zhuo
RuneReader is fine with UTF16 or any other character encoding Fixes #49178 Change-Id: I08a5ac205e095349d451d3b60411eaeebc3aa563 Reviewed-on: https://go-review.googlesource.com/c/go/+/359334 Trust: Meng Zhuo <mzh@golangcn.org> Reviewed-by: Meng Zhuo <mzh@golangcn.org> Reviewed-by: Ian Lance Taylor <iant@golang.org> Reviewed-by: Rob Pike <r@golang.org> Run-TryBot: Meng Zhuo <mzh@golangcn.org> TryBot-Result: Go Bot <gobot@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-09-28io: update ByteScanner and RuneScanner docs to match long-standing ↵Bryan C. Mills
implementations Do not require the byte or rune unread by the call to match the last return from ReadByte or ReadRune, since in practice the implementations of these methods (especially ReadByte) may also unread bytes from other Read-style methods without reporting an error. Explicitly allow the Seek-like behavior implemented by bytes.Reader and bufio.Reader, which can “unread” bytes that were never actually read. Explicitly allow ReadByte or ReadRune to return an error after a call to a non-ReadByte or non-ReadRune operation respectively. (In practice, implementations today allow very liberal calls to ReadByte and tend to be more strict about ReadRune, but it seems simpler to keep the two definitions completely parallel.) Like CL 349054, this is techincally a breaking change, but given the long-standing behavior of the implementations in the Go standard library (such as strings.Reader, bytes.Buffer, and bufio.Reader), I believe it falls under the “specification errors” exception to the Go 1 compatibility policy. Fixes #48449 Change-Id: I61696a59770fe83c667377ba25a072762d3f6f19 Reviewed-on: https://go-review.googlesource.com/c/go/+/351809 Trust: Bryan C. Mills <bcmills@google.com> Run-TryBot: Bryan C. Mills <bcmills@google.com> TryBot-Result: Go Bot <gobot@golang.org> Reviewed-by: Rob Pike <r@golang.org>
2021-09-27io: avoid integer overflow in NewSectionReaderIan Lance Taylor
Fixes #48620 Change-Id: I37a5909ad27dc4a170929cb2e2ed1045cf524d59 Reviewed-on: https://go-review.googlesource.com/c/go/+/352629 Trust: Ian Lance Taylor <iant@golang.org> Run-TryBot: Ian Lance Taylor <iant@golang.org> Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org> TryBot-Result: Go Bot <gobot@golang.org>
2021-09-22io: fix spelling in documentationjiahua wang
Change-Id: Ie23a9f1300a803d9c713e82b0d892dd90333ca7b Reviewed-on: https://go-review.googlesource.com/c/go/+/351371 Reviewed-by: Robert Griesemer <gri@golang.org> Reviewed-by: Ian Lance Taylor <iant@golang.org>
2021-09-22io: fix spelling in documentation for writerFuncjiahua wang
Change-Id: I9f55188859944e1b2b140d3547bcfcb335c5ff50 Reviewed-on: https://go-review.googlesource.com/c/go/+/351370 Reviewed-by: Ian Lance Taylor <iant@golang.org> Trust: Robert Griesemer <gri@golang.org>
2021-09-21io: relax documented Seeker invariants that do not hold in practiceBryan C. Mills
Use “or” instead of “and” to describe error behavior. On error, nearly all Seeker implementations in the Go repo return 0 instead of “the new offset”. (Arguably on error “the new offset” is the same as the previous offset, but some Seeker implementations don't have that offset readily available.) Don't claim that “any positive offsite is legal”. In practice, most of the Seeker implementations within the Go standard library do not allow “[s]eeking to any [arbitrary] positive offset”: some reject all out-of-bounds offsets, and some reject only a subset that happen to overflow some underlying representation. Since some positive offsets may be rejected, we cannot claim that seeking to those offsets “is legal”. However, to avoid invalidating existing Seeker implemetations we must not require an implementation to reject invalid positive offsets either. This is technically a breaking change, since callers of Seek are no longer allowed to assume that a Seek resulting in an arbitrary positive offset will succeed. However, since basically none of the existing implementations actually conformed to the documented behavior I believe this falls under the “specification errors” exception to the Go 1 compatibility policy. Fixes #48316 Change-Id: Ib1b478599b20ad5361bcc97fe8ceb84f74e6d971 Reviewed-on: https://go-review.googlesource.com/c/go/+/349054 Trust: Bryan C. Mills <bcmills@google.com> Run-TryBot: Bryan C. Mills <bcmills@google.com> TryBot-Result: Go Bot <gobot@golang.org> Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org> Reviewed-by: Ian Lance Taylor <iant@golang.org> Reviewed-by: Rob Pike <r@golang.org>
2021-08-19io: unexport internal methodsRoger Peppe
The methods on the pipe type don't need to be exported. Doing so sets a bad precedent that it's OK to export methods to indicate an internal public API. That's not a good idea in general, because exported methods increase cognitive load when reading code: the reader needs to consider whether the exported method might be used via some external interface or reflection. Change-Id: Ib13f1b3f9fe0ff251628f31b776182a0953268ee Reviewed-on: https://go-review.googlesource.com/c/go/+/341409 Reviewed-by: Daniel Martí <mvdan@mvdan.cc> Reviewed-by: Joe Tsai <thebrokentoaster@gmail.com> Reviewed-by: Joe Tsai <joetsai@digital-static.net> Trust: Daniel Martí <mvdan@mvdan.cc>
2021-08-02io/fs: don't use absolute path in DirEntry.Name docIan Lance Taylor
Fixes #47485 Change-Id: I64ac00905a403b7594c706141679051a93058a31 Reviewed-on: https://go-review.googlesource.com/c/go/+/338889 Trust: Ian Lance Taylor <iant@golang.org> Run-TryBot: Ian Lance Taylor <iant@golang.org> TryBot-Result: Go Bot <gobot@golang.org> Reviewed-by: Dmitri Shuralyov <dmitshur@golang.org>
2021-06-02io/fs: minor corrections to Sub docsIan Lance Taylor
Fixes #44376 Change-Id: I9cd21adb9d4d434c3d8b8eb8af3042b70c763ea1 Reviewed-on: https://go-review.googlesource.com/c/go/+/296389 Trust: Ian Lance Taylor <iant@golang.org> Reviewed-by: Russ Cox <rsc@golang.org>
2021-05-21io/fs: added an example for io/fs.WalkDirAdam Mitha
The documentation currently does not show how to get an `FS` instance for the operating system's filesystem. This example demonstrates how to accomplish this using the `os` package. Fixes #46083 Change-Id: I053111c12ab09ef13f0d04fcdff8a6ea0dccf379 Reviewed-on: https://go-review.googlesource.com/c/go/+/319989 Run-TryBot: Ian Lance Taylor <iant@golang.org> TryBot-Result: Go Bot <gobot@golang.org> Reviewed-by: Ian Lance Taylor <iant@golang.org> Trust: Emmanuel Odeke <emmanuel@orijtech.com>
2021-04-21io/fs: document that caller can modify slice returned by ReadFileIan Lance Taylor
Also add a test to testing/fstest. Fixes #45186 Change-Id: I00e5f46ccd5269dbc266a8f2ebc9a62ebb1297b8 Reviewed-on: https://go-review.googlesource.com/c/go/+/311649 Trust: Ian Lance Taylor <iant@golang.org> Reviewed-by: Russ Cox <rsc@golang.org>
2021-04-03io/fs: implement subFS.SubDrew Richardson
Calling fs.Sub with the result of fs.Sub multiple times creates a deep call stack for Open and other methods. Enhance the fs.FS returned by fs.Sub to implement fs.SubFS and reduce the call stack. Fixes #45349 Change-Id: I10e10501e030176e10e2ae5ad260212e5c784bed Reviewed-on: https://go-review.googlesource.com/c/go/+/306769 Run-TryBot: Ian Lance Taylor <iant@golang.org> TryBot-Result: Go Bot <gobot@golang.org> Reviewed-by: Ian Lance Taylor <iant@golang.org> Trust: Emmanuel Odeke <emmanuel@orijtech.com>
2021-03-25io/fs: implement FileInfoToDirEntryMichel Levieux
Implements FileInfoToDirEntry which converts an fs.FileInfo to fs.DirEntry. Fixes #42387. Change-Id: Ie723b6ed583c6c5ecf22bbe64e3b6496f5114254 Reviewed-on: https://go-review.googlesource.com/c/go/+/293649 Run-TryBot: Ian Lance Taylor <iant@golang.org> TryBot-Result: Go Bot <gobot@golang.org> Reviewed-by: Ian Lance Taylor <iant@golang.org> Reviewed-by: Emmanuel Odeke <emmanuel@orijtech.com>
2021-03-23io: fix spelling in documentation for io.DiscardSimão Gomes Viana
In the process of refactoring ioutil.Discard to io.Discard in CL 263141 "an" should have been changed to "a" but was likely missed in the process. This commit corrects the spelling of the documentation. Change-Id: I0609c45878291f8f01560efc3f3e6fba191e095b GitHub-Last-Rev: e3257ca272dff42ed7d07b6e6a5fc49493772653 GitHub-Pull-Request: golang/go#45190 Reviewed-on: https://go-review.googlesource.com/c/go/+/304209 Reviewed-by: Ian Lance Taylor <iant@golang.org> Reviewed-by: Robert Griesemer <gri@golang.org> Trust: Robert Griesemer <gri@golang.org>
2021-03-19io/ioutil: use correct Go version in redirection commentsIan Lance Taylor
Change-Id: I282f428137ca3360a58167c94e26f3dfdf59fb63 Reviewed-on: https://go-review.googlesource.com/c/go/+/302756 Trust: Ian Lance Taylor <iant@golang.org> Run-TryBot: Ian Lance Taylor <iant@golang.org> TryBot-Result: Go Bot <gobot@golang.org> Reviewed-by: Emmanuel Odeke <emmanuel@orijtech.com>
2021-03-13io/fs: use testing.T.TempDir in TestWalkDirTobias Klauser
Change-Id: I805ad51332e4efe27d47f6c6e3b0af945e0d4aa0 Reviewed-on: https://go-review.googlesource.com/c/go/+/301489 Trust: Tobias Klauser <tobias.klauser@gmail.com> Run-TryBot: Tobias Klauser <tobias.klauser@gmail.com> TryBot-Result: Go Bot <gobot@golang.org> Reviewed-by: Emmanuel Odeke <emmanuel@orijtech.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>
2021-03-11io/fs: clarify additional File interface docsJosh Bleecher Snyder
Emphasize ReadDirFile. It isn't really optional, and all filesystems have at least one directory ("."). The remaining two additional interfaces are optimizations. Call them that. Fully qualify package package io identifiers. Change-Id: Ibc425a5dfd27e08c2c10c353f780e4a6304cfd87 Reviewed-on: https://go-review.googlesource.com/c/go/+/296390 Trust: Josh Bleecher Snyder <josharian@gmail.com> Run-TryBot: Josh Bleecher Snyder <josharian@gmail.com> TryBot-Result: Go Bot <gobot@golang.org> Reviewed-by: Ian Lance Taylor <iant@golang.org>
2021-02-24io/ioutil: forward TempFile and TempDir to os packageIan Lance Taylor
For #42026 Fixes #44311 Change-Id: I3dabcf902d155f95800b4adf1d7578906a194ce6 Reviewed-on: https://go-review.googlesource.com/c/go/+/285378 Trust: Ian Lance Taylor <iant@golang.org> Run-TryBot: Ian Lance Taylor <iant@golang.org> TryBot-Result: Go Bot <gobot@golang.org> Reviewed-by: Emmanuel Odeke <emmanuel@orijtech.com>
2021-02-23ios/fs: mention f.dir in (*subFS).fixErr godocTobias Klauser
There is no dir parameter to (f *subFS).fixErr. Change-Id: I49e42bac5e102cfab0d289658d9871429cfec515 Reviewed-on: https://go-review.googlesource.com/c/go/+/292389 Trust: Tobias Klauser <tobias.klauser@gmail.com> Run-TryBot: Tobias Klauser <tobias.klauser@gmail.com> TryBot-Result: Go Bot <gobot@golang.org> Reviewed-by: Ian Lance Taylor <iant@golang.org>
2021-02-11io/fs: allow backslash in ValidPath, reject in os.DirFS.OpenRuss Cox
Rejecting backslash introduces problems with presenting underlying OS file systems that contain names with backslash. Rejecting backslash also does not Windows-proof the syntax, because colon can also be a path separator. And we are not going to reject colon from all names. So don't reject backslash either. There is a similar problem on Windows with names containing slashes, but those are more difficult (though not impossible) to create. Also document and enforce that paths must be UTF-8. Fixes #44166. Change-Id: Iac7a9a268025c1fd31010dbaf3f51e1660c7ae2a Reviewed-on: https://go-review.googlesource.com/c/go/+/290709 TryBot-Result: Go Bot <gobot@golang.org> Reviewed-by: Bryan C. Mills <bcmills@google.com> Trust: Russ Cox <rsc@golang.org> Run-TryBot: Russ Cox <rsc@golang.org>
2021-02-09io/fs: backslash is always a glob meta characterIan Lance Taylor
Fixes #44171 Change-Id: I2d3437a2f5b9fa0358e4664e1a8eacebed975eed Reviewed-on: https://go-review.googlesource.com/c/go/+/290512 Trust: Ian Lance Taylor <iant@golang.org> Run-TryBot: Ian Lance Taylor <iant@golang.org> TryBot-Result: Go Bot <gobot@golang.org> Reviewed-by: Rob Pike <r@golang.org> Reviewed-by: Russ Cox <rsc@golang.org>
2021-02-05embed, io/fs: clarify that leading and trailing slashes are disallowedJay Conrod
Fixes #44012 Change-Id: I5782cea301a65ae12ba870ff1e6b2e0a2651dc09 Reviewed-on: https://go-review.googlesource.com/c/go/+/290071 Run-TryBot: Jay Conrod <jayconrod@google.com> Reviewed-by: Bryan C. Mills <bcmills@google.com> TryBot-Result: Go Bot <gobot@golang.org> Trust: Jay Conrod <jayconrod@google.com>
2021-01-22io/ioutil: fix example test for WriteFile to allow it to run in the playgroundPantonshire
The example for WriteFile assumed the existence of a testdata/ directory, which is not present on the playground. The example now writes the file to the current working directory, rather than to testdata/. Fixes #32916 Change-Id: I577caac7e67ba9d9941b2dd19346ad5ff61e78d9 GitHub-Last-Rev: 40f14e0adc4ebc00fb2946fe0cbaf8e0cb99f62c GitHub-Pull-Request: golang/go#43757 Reviewed-on: https://go-review.googlesource.com/c/go/+/284452 Run-TryBot: Ian Lance Taylor <iant@golang.org> TryBot-Result: Go Bot <gobot@golang.org> Reviewed-by: Ian Lance Taylor <iant@golang.org> Trust: Bryan C. Mills <bcmills@google.com>
2021-01-08io/fs: minor corrections to Glob docIan Lance Taylor
The documentation for Glob was copied from filepath.Glob, and needs a bit of tweaking: paths are not rooted at slash; the separator is always '/'. Fixes #43537 Change-Id: Id64daa137e2762b66a82a5b9e60bbe603f4e2f5c Reviewed-on: https://go-review.googlesource.com/c/go/+/282173 Trust: Ian Lance Taylor <iant@golang.org> Reviewed-by: Russ Cox <rsc@golang.org>
2021-01-08io/fs: minor corrections to Glob release dateMeng Zhuo
io/fs is introduced in 2020, not 2009 nor 2010 Change-Id: I7d63aae17b1f8c3af1ded2f639e3fb76ff2aea81 Reviewed-on: https://go-review.googlesource.com/c/go/+/282232 Trust: Meng Zhuo <mzh@golangcn.org> Run-TryBot: Meng Zhuo <mzh@golangcn.org> TryBot-Result: Go Bot <gobot@golang.org> Reviewed-by: Ian Lance Taylor <iant@golang.org>