Skip to content

Commit 4008e07

Browse files
neildgopherbot
authored andcommitted
io/fs: move path name documentation up to the package doc comment
Perhaps surprisingly to users, io/fs path names are slash-separated. Move the documentation for path names up to the top of the package rather than burying it in the ValidPath documentation. Change-Id: Id338df07c74a16be74c687ac4c45e0513ee40a8c Reviewed-on: https://go-review.googlesource.com/c/go/+/708616 LUCI-TryBot-Result: Go LUCI <[email protected]> Reviewed-by: Alan Donovan <[email protected]> Auto-Submit: Damien Neil <[email protected]>
1 parent 0e4e2e6 commit 4008e07

File tree

1 file changed

+16
-6
lines changed

1 file changed

+16
-6
lines changed

src/io/fs/fs.go

Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,19 @@
66
// A file system can be provided by the host operating system
77
// but also by other packages.
88
//
9+
// # Path Names
10+
//
11+
// The interfaces in this package all operate on the same
12+
// path name syntax, regardless of the host operating system.
13+
//
14+
// Path names are UTF-8-encoded,
15+
// unrooted, slash-separated sequences of path elements, like “x/y/z”.
16+
// Path names must not contain an element that is “.” or “..” or the empty string,
17+
// except for the special case that the name "." may be used for the root directory.
18+
// Paths must not start or end with a slash: “/x” and “x/” are invalid.
19+
//
20+
// # Testing
21+
//
922
// See the [testing/fstest] package for support with testing
1023
// implementations of file systems.
1124
package fs
@@ -41,16 +54,13 @@ type FS interface {
4154
// ValidPath reports whether the given path name
4255
// is valid for use in a call to Open.
4356
//
44-
// Path names passed to open are UTF-8-encoded,
45-
// unrooted, slash-separated sequences of path elements, like “x/y/z”.
46-
// Path names must not contain an element that is “.” or “..” or the empty string,
47-
// except for the special case that the name "." may be used for the root directory.
48-
// Paths must not start or end with a slash: “/x” and “x/” are invalid.
49-
//
5057
// Note that paths are slash-separated on all systems, even Windows.
5158
// Paths containing other characters such as backslash and colon
5259
// are accepted as valid, but those characters must never be
5360
// interpreted by an [FS] implementation as path element separators.
61+
// See the [Path Names] section for more details.
62+
//
63+
// [Path Names]: https://pkg.go.dev/io/fs#hdr-Path_Names
5464
func ValidPath(name string) bool {
5565
if !utf8.ValidString(name) {
5666
return false

0 commit comments

Comments
 (0)