Commit 9852b4b0 authored by Eric Rutherford's avatar Eric Rutherford Committed by Rob Pike

path: minor changes to improve documentation for Join

Reworking the comments in path to call out how leading
empty elements are treated. Also updating filepath.Join
since it shared much of the wording from path.Join.

Updates #35655

Change-Id: I5b15c5d36e9d19831ed39e6bcc7f2fd6c1330033
Reviewed-on: https://go-review.googlesource.com/c/go/+/207797Reviewed-by: default avatarRob Pike <r@golang.org>
parent fbcfa6a5
...@@ -201,11 +201,13 @@ func Split(path string) (dir, file string) { ...@@ -201,11 +201,13 @@ func Split(path string) (dir, file string) {
return path[:i+1], path[i+1:] return path[:i+1], path[i+1:]
} }
// Join joins any number of path elements into a single path, adding // Join joins any number of path elements into a single path,
// a Separator if necessary. Join calls Clean on the result; in particular, // separating them with an OS specific Separator. Empty elements
// all empty strings are ignored. // are ignored. The result is Cleaned. However, if the argument
// On Windows, the result is a UNC path if and only if the first path // list is empty or all its elements are empty, Join returns
// element is a UNC path. // an empty string.
// On Windows, the result will only be a UNC path if the first
// non-empty element is a UNC path.
func Join(elem ...string) string { func Join(elem ...string) string {
return join(elem) return join(elem)
} }
......
...@@ -149,10 +149,11 @@ func Split(path string) (dir, file string) { ...@@ -149,10 +149,11 @@ func Split(path string) (dir, file string) {
return path[:i+1], path[i+1:] return path[:i+1], path[i+1:]
} }
// Join joins the argument's path elements into a single path, // Join joins any number of path elements into a single path,
// separating them with slashes. The result is Cleaned. However, // separating them with slashes. Empty elements are ignored.
// if the argument list is empty or all its elements are empty, // The result is Cleaned. However, if the argument list is
// Join returns an empty string. // empty or all its elements are empty, Join returns
// an empty string.
func Join(elem ...string) string { func Join(elem ...string) string {
for i, e := range elem { for i, e := range elem {
if e != "" { if e != "" {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment