li_tang
(li tang)
1
I created a temporary file and renamed it with following statements:
tmp, err := ioutil.TempFile(".", "tmpInter")
os.Rename(tmp.Name(),"mr-0-0")
, but the permissions on the file changed, as shown in the figure:
This prevented me from opening the file again.
What’s wrong with my program and how can I get it right?
skillian
(Sean Killian)
2
I’m not sure if this is relevant or not, but you’re renaming the file while it’s still open. That might not be the issue, but I would recommend:
- Close the file returned by ioutil.TempFile before attempting to rename it, or at least close it at some point by calling its Close method.
- Don’t discard errors! Maybe ioutil.TempFile is returning an error; maybe os.Rename is.
1 Like
system
(system)
Closed
3
This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.