You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Does this issue reproduce with the latest release?
Present in Go 1.17.1
What operating system and processor architecture are you using (go env)?
linux amd64 and darwin
What did you do?
Calling ioutil.TempFile(".","something"), the returned file has a different
response for Name() between go1.17 and go.1.16. In 1.17 the file is qualified
with ./, in 1.16 it was not.
For most practical purposes this is fine, but it breaks when passing the f.Name() directly
to (e.g.) docker daemon, which wants it without the prefix.
Same response for filename stem from 1.16 and 1.17
What did you see instead?
1.17 includes the ./ prefix.
The text was updated successfully, but these errors were encountered:
tcolgate
changed the title
ioutil: TempFile response varies between 1.16 and 1.17
ioutil: TempFile Name() stem response varies between 1.16 and 1.17
Sep 14, 2021
This appears to be a consequence of the fact that os.CreateTemp and ioutil.TempFile behave slightly differently. In 1.17 we redirected the latter to use the former.
dmitshur
changed the title
ioutil: TempFile Name() stem response varies between 1.16 and 1.17
io/ioutil: TempFile Name() stem response varies between 1.16 and 1.17
Sep 14, 2021
In 1.16 ioutil.TempFile called filepath.Join to join the directory and file name. filepath.Join calls filepath.Clean, which eliminates path elements that are just .. In 1.17 ioutil.TempFile redirects to the newer os.CreateTemp, as @randall77 says. That function does not use filepath.Join because the os package can't depend on the path/filepath package. It uses a much simpler version which doesn't eliminate . elements.
This is a change in behavior but it doesn't strike me as being a bug. We don't document any particular behavior for ioutil.TempFile, and passing a relative path as the directory argument is not the usual case. The workaround for this would be to call filepath.Clean on the file name.
Thanks, figured that may be the case, but thought the difference was worth reporting. (the real mystery is why docker daemon is fine with this for some dockerfiles and not for others, but that's definitely not your problem.
What version of Go are you using (
go version
)?Go 1.17 and Go 1.16
Does this issue reproduce with the latest release?
Present in Go 1.17.1
What operating system and processor architecture are you using (
go env
)?linux amd64 and darwin
What did you do?
Calling
ioutil.TempFile(".","something")
, the returned file has a differentresponse for Name() between go1.17 and go.1.16. In 1.17 the file is qualified
with
./
, in 1.16 it was not.For most practical purposes this is fine, but it breaks when passing the f.Name() directly
to (e.g.) docker daemon, which wants it without the prefix.
What did you expect to see?
Same response for filename stem from 1.16 and 1.17
What did you see instead?
1.17 includes the ./ prefix.
The text was updated successfully, but these errors were encountered: