Skip to content
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: Join documentation is misleading regarding Cleaned #29875

Closed
rillig opened this issue Jan 22, 2019 · 8 comments

Comments

@rillig
Copy link
Contributor

commented Jan 22, 2019

As of Go 1.11.4, the documentation of path.Join says:

Join joins any number of path elements into a single path, adding a separating slash if necessary. The result is Cleaned; in particular, all empty strings are ignored.

Since Cleaned is written in uppercase, this suggests that path.Clean is called on the preliminary result of Join. For most cases this is true, but for the case of only empty filenames, it isn't. There, path.Join("") returns an empty string while path.Clean("") returns dot.

See https://play.golang.org/p/rjq7up_HplU.

@robpike

This comment has been minimized.

Copy link
Contributor

commented Jan 22, 2019

A bug in the code, but maybe too hard to fix. Might need a documentation fix instead.

@FiloSottile FiloSottile added this to the Go1.13 milestone Jan 23, 2019

@Avni-Sharma

This comment has been minimized.

Copy link

commented Mar 5, 2019

Has this been updated yet?

@rillig

This comment has been minimized.

Copy link
Contributor Author

commented Mar 5, 2019

Has this been updated yet?

No, otherwise the Gerrit change request would be linked with this issue.

@agnivade

This comment has been minimized.

Copy link
Member

commented Jul 7, 2019

There is actually a test case for path.Join which joins two empty strings and checks the output is an empty string. So not sure if it is a bug.

For most cases this is true, but for the case of only empty filenames, it isn't. There, path.Join("") returns an empty string while path.Clean("") returns dot.

That is because path.Clean is called only for non-empty strings. Which is what the documentation tries to say. But I agree this part ; in particular, all empty strings are ignored. is not clear that Clean is being called after ignoring all empty strings. I believe updating the docs is the safest recourse.

@agnivade agnivade added the help wanted label Jul 7, 2019

@andybons andybons modified the milestones: Go1.13, Go1.14 Jul 8, 2019

@agnivade

This comment has been minimized.

Copy link
Member

commented Aug 6, 2019

@shivi28 - would you like to work on this ?

@erutherford

This comment has been minimized.

Copy link
Contributor

commented Sep 6, 2019

@agnivade I can work on this unless @shivi28 already has or was planning to.

@agnivade

This comment has been minimized.

Copy link
Member

commented Sep 7, 2019

There hasn't been a response, so feel free to take it up.

@gopherbot

This comment has been minimized.

Copy link

commented Sep 9, 2019

Change https://golang.org/cl/194339 mentions this issue: path: inprove documentation to call out cases where Clean is called

@gopherbot gopherbot closed this in 5e907e3 Sep 9, 2019

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
8 participants
You can’t perform that action at this time.