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
io/ioutil: document that TempDir's "prefix" should not contain a slash #10003
Comments
I think it would fail even if it contained a slash. The prefix is for the file name, not for the path. |
What does that have to do with this bug? The documentation for TempDir says nothing about usernames. Perhaps the documentation of TempDir just needs to say not to put slashes in the prefix. |
Maybe it's worth documenting that, but the docs do say the "TempFile creates a new temporary file in the directory dir with a name beginning with prefix." A file name shouldn't contain a slash, so the prefix shouldn't contain a slash. Not sure how explicit we should be. |
As well as documenting this we should probably check inside the preamble of the function that the prefix doesn't split according to the native filepath.SplitList and return an error if it does. |
On Wed, Feb 25, 2015 at 6:23 PM, Dave Cheney notifications@github.com
|
Yeah, I have actually wanted to do this before. On 26 February 2015 at 10:27, Minux Ma notifications@github.com wrote:
|
Looking at the documentation again, it looks to me like |
I think this is documented clearly enough and working as intended. If the subdirectory exists I see no reason to reject the call, but I also see no reason to create the subdirectory. It seems fine as is. The original reporter (@peterstace) seems to agree, so closing. |
What version of Go are you using (go version)?
What operating system and processor architecture are you using?
What did you do?
go run bug.go
. This is a minimal reproduction of the problem -- the real situation occurred when username given by theos/user
package is embedded within the prefix. On Windows, the username often contains backslashes.What did you expect to see?
2015/02/26 10:01:04 C:\Users\petsta\AppData\Local\Temp\foo\bar428871999<nil>
2015/02/26 10:01:04 C:\Users\petsta\AppData\Local\Temp\foo_bar428871999<nil>
2015/02/26 10:01:04 C:\Users\petsta\AppData\Local\Temp\foobar428871999<nil>
What did you see instead?
2015/02/26 09:59:53 mkdir C:\Users\petsta\AppData\Local\Temp\foo\bar288812899: The system cannot find the path specified.
The text was updated successfully, but these errors were encountered: