Skip to content

Commit 0c7e5d3

Browse files
cuishuanggopherbot
authored andcommitted
path: add available godoc link
Change-Id: I6d40a59cde4c3f1d5094f5126fdbc1195285195f Reviewed-on: https://go-review.googlesource.com/c/go/+/539577 Reviewed-by: Cherry Mui <[email protected]> LUCI-TryBot-Result: Go LUCI <[email protected]> Reviewed-by: Rob Pike <[email protected]> Reviewed-by: Dmitri Shuralyov <[email protected]> Auto-Submit: Dmitri Shuralyov <[email protected]>
1 parent 3e67f46 commit 0c7e5d3

File tree

4 files changed

+23
-23
lines changed

4 files changed

+23
-23
lines changed

src/path/filepath/match.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ var ErrBadPattern = errors.New("syntax error in pattern")
3535
// lo '-' hi matches character c for lo <= c <= hi
3636
//
3737
// Match requires pattern to match all of name, not just a substring.
38-
// The only possible returned error is ErrBadPattern, when pattern
38+
// The only possible returned error is [ErrBadPattern], when pattern
3939
// is malformed.
4040
//
4141
// On Windows, escaping is disabled. Instead, '\\' is treated as
@@ -233,11 +233,11 @@ func getEsc(chunk string) (r rune, nchunk string, err error) {
233233

234234
// Glob returns the names of all files matching pattern or nil
235235
// if there is no matching file. The syntax of patterns is the same
236-
// as in Match. The pattern may describe hierarchical names such as
237-
// /usr/*/bin/ed (assuming the Separator is '/').
236+
// as in [Match]. The pattern may describe hierarchical names such as
237+
// /usr/*/bin/ed (assuming the [Separator] is '/').
238238
//
239239
// Glob ignores file system errors such as I/O errors reading directories.
240-
// The only possible returned error is ErrBadPattern, when pattern
240+
// The only possible returned error is [ErrBadPattern], when pattern
241241
// is malformed.
242242
func Glob(pattern string) (matches []string, err error) {
243243
return globWithLimit(pattern, 0)

src/path/filepath/path.go

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ const (
7373
// by purely lexical processing. It applies the following rules
7474
// iteratively until no further processing can be done:
7575
//
76-
// 1. Replace multiple Separator elements with a single one.
76+
// 1. Replace multiple [Separator] elements with a single one.
7777
// 2. Eliminate each . path name element (the current directory).
7878
// 3. Eliminate each inner .. path name element (the parent directory)
7979
// along with the non-.. element that precedes it.
@@ -231,15 +231,15 @@ func FromSlash(path string) string {
231231
return strings.ReplaceAll(path, "/", string(Separator))
232232
}
233233

234-
// SplitList splits a list of paths joined by the OS-specific ListSeparator,
234+
// SplitList splits a list of paths joined by the OS-specific [ListSeparator],
235235
// usually found in PATH or GOPATH environment variables.
236236
// Unlike strings.Split, SplitList returns an empty slice when passed an empty
237237
// string.
238238
func SplitList(path string) []string {
239239
return splitList(path)
240240
}
241241

242-
// Split splits path immediately following the final Separator,
242+
// Split splits path immediately following the final [Separator],
243243
// separating it into a directory and file name component.
244244
// If there is no Separator in path, Split returns an empty dir
245245
// and file set to path.
@@ -254,7 +254,7 @@ func Split(path string) (dir, file string) {
254254
}
255255

256256
// Join joins any number of path elements into a single path,
257-
// separating them with an OS specific Separator. Empty elements
257+
// separating them with an OS specific [Separator]. Empty elements
258258
// are ignored. The result is Cleaned. However, if the argument
259259
// list is empty or all its elements are empty, Join returns
260260
// an empty string.
@@ -281,7 +281,7 @@ func Ext(path string) string {
281281
// links.
282282
// If path is relative the result will be relative to the current directory,
283283
// unless one of the components is an absolute symbolic link.
284-
// EvalSymlinks calls Clean on the result.
284+
// EvalSymlinks calls [Clean] on the result.
285285
func EvalSymlinks(path string) (string, error) {
286286
return evalSymlinks(path)
287287
}
@@ -290,7 +290,7 @@ func EvalSymlinks(path string) (string, error) {
290290
// If the path is not absolute it will be joined with the current
291291
// working directory to turn it into an absolute path. The absolute
292292
// path name for a given file is not guaranteed to be unique.
293-
// Abs calls Clean on the result.
293+
// Abs calls [Clean] on the result.
294294
func Abs(path string) (string, error) {
295295
return abs(path)
296296
}
@@ -308,12 +308,12 @@ func unixAbs(path string) (string, error) {
308308

309309
// Rel returns a relative path that is lexically equivalent to targpath when
310310
// joined to basepath with an intervening separator. That is,
311-
// Join(basepath, Rel(basepath, targpath)) is equivalent to targpath itself.
311+
// [Join](basepath, Rel(basepath, targpath)) is equivalent to targpath itself.
312312
// On success, the returned path will always be relative to basepath,
313313
// even if basepath and targpath share no elements.
314314
// An error is returned if targpath can't be made relative to basepath or if
315315
// knowing the current working directory would be necessary to compute it.
316-
// Rel calls Clean on the result.
316+
// Rel calls [Clean] on the result.
317317
func Rel(basepath, targpath string) (string, error) {
318318
baseVol := VolumeName(basepath)
319319
targVol := VolumeName(targpath)
@@ -396,7 +396,7 @@ var SkipDir error = fs.SkipDir
396396
// as an error by any function.
397397
var SkipAll error = fs.SkipAll
398398

399-
// WalkFunc is the type of the function called by Walk to visit each
399+
// WalkFunc is the type of the function called by [Walk] to visit each
400400
// file or directory.
401401
//
402402
// The path argument contains the argument to Walk as a prefix.
@@ -412,9 +412,9 @@ var SkipAll error = fs.SkipAll
412412
// The info argument is the fs.FileInfo for the named path.
413413
//
414414
// The error result returned by the function controls how Walk continues.
415-
// If the function returns the special value SkipDir, Walk skips the
415+
// If the function returns the special value [SkipDir], Walk skips the
416416
// current directory (path if info.IsDir() is true, otherwise path's
417-
// parent directory). If the function returns the special value SkipAll,
417+
// parent directory). If the function returns the special value [SkipAll],
418418
// Walk skips all remaining files and directories. Otherwise, if the function
419419
// returns a non-nil error, Walk stops entirely and returns that error.
420420
//
@@ -425,14 +425,14 @@ var SkipAll error = fs.SkipAll
425425
//
426426
// Walk calls the function with a non-nil err argument in two cases.
427427
//
428-
// First, if an os.Lstat on the root directory or any directory or file
428+
// First, if an [os.Lstat] on the root directory or any directory or file
429429
// in the tree fails, Walk calls the function with path set to that
430430
// directory or file's path, info set to nil, and err set to the error
431431
// from os.Lstat.
432432
//
433433
// Second, if a directory's Readdirnames method fails, Walk calls the
434434
// function with path set to the directory's path, info, set to an
435-
// fs.FileInfo describing the directory, and err set to the error from
435+
// [fs.FileInfo] describing the directory, and err set to the error from
436436
// Readdirnames.
437437
type WalkFunc func(path string, info fs.FileInfo, err error) error
438438

@@ -514,7 +514,7 @@ func walk(path string, info fs.FileInfo, walkFn WalkFunc) error {
514514
// directory in the tree, including root.
515515
//
516516
// All errors that arise visiting files and directories are filtered by fn:
517-
// see the fs.WalkDirFunc documentation for details.
517+
// see the [fs.WalkDirFunc] documentation for details.
518518
//
519519
// The files are walked in lexical order, which makes the output deterministic
520520
// but requires WalkDir to read an entire directory into memory before proceeding
@@ -542,15 +542,15 @@ func WalkDir(root string, fn fs.WalkDirFunc) error {
542542
// directory in the tree, including root.
543543
//
544544
// All errors that arise visiting files and directories are filtered by fn:
545-
// see the WalkFunc documentation for details.
545+
// see the [WalkFunc] documentation for details.
546546
//
547547
// The files are walked in lexical order, which makes the output deterministic
548548
// but requires Walk to read an entire directory into memory before proceeding
549549
// to walk that directory.
550550
//
551551
// Walk does not follow symbolic links.
552552
//
553-
// Walk is less efficient than WalkDir, introduced in Go 1.16,
553+
// Walk is less efficient than [WalkDir], introduced in Go 1.16,
554554
// which avoids calling os.Lstat on every visited file or directory.
555555
func Walk(root string, fn WalkFunc) error {
556556
info, err := os.Lstat(root)
@@ -611,7 +611,7 @@ func Base(path string) string {
611611
}
612612

613613
// Dir returns all but the last element of path, typically the path's directory.
614-
// After dropping the final element, Dir calls Clean on the path and trailing
614+
// After dropping the final element, Dir calls [Clean] on the path and trailing
615615
// slashes are removed.
616616
// If the path is empty, Dir returns ".".
617617
// If the path consists entirely of separators, Dir returns a single separator.

src/path/match.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ var ErrBadPattern = errors.New("syntax error in pattern")
3232
// lo '-' hi matches character c for lo <= c <= hi
3333
//
3434
// Match requires pattern to match all of name, not just a substring.
35-
// The only possible returned error is ErrBadPattern, when pattern
35+
// The only possible returned error is [ErrBadPattern], when pattern
3636
// is malformed.
3737
func Match(pattern, name string) (matched bool, err error) {
3838
Pattern:

src/path/path.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -214,7 +214,7 @@ func IsAbs(path string) bool {
214214
}
215215

216216
// Dir returns all but the last element of path, typically the path's directory.
217-
// After dropping the final element using Split, the path is Cleaned and trailing
217+
// After dropping the final element using [Split], the path is Cleaned and trailing
218218
// slashes are removed.
219219
// If the path is empty, Dir returns ".".
220220
// If the path consists entirely of slashes followed by non-slash bytes, Dir

0 commit comments

Comments
 (0)