-
Notifications
You must be signed in to change notification settings - Fork 17.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
path/filepath: Join documentation inconsistencies with path.Join #35655
Comments
/cc @erutherford who worked on the updated documentation and @robpike, who owns |
Sorry, I meant to respond to this over the weekend, but ended up being sick instead :)
You're right this could have been clearer. Any leading empty strings are ignored in
I can take a look at updating this too. |
Change https://golang.org/cl/207797 mentions this issue: |
@erutherford, thanks! No hurry, I'm never sure if people see my replies on closed issues... |
@erutherford, "are" repetition typo in "Any leading empty elements are are ignored". Your wording SGTM, but consider even just "Empty elements are ignored", since non leading ones don't make any difference after |
@pam4 thanks for catching that, I've corrected the error and adopted your suggestion. |
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/+/207797 Reviewed-by: Rob Pike <r@golang.org>
This is a follow-up to #29875, which is closed.
Problems:
path.Join
docs, butfilepath.Join
has the same problem and should be fixed too.path.Join("", "foo")
results in"foo"
rather than"/foo"
.New:
Old:
I think it should be clear that
Join
can return the empty string, but it should be also clear that empty strings at the beginning don't make the path absolute.While I'm at it, I'm also confused by
path.Dir
:It should probably read "If the path consists entirely of slashes possibly followed by non-slash bytes" or "If the path consists entirely of slashes followed by zero or more non-slash bytes", otherwise the last sentence ("In any other case ...") is false.
The text was updated successfully, but these errors were encountered: