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

os: document that os.Rename will overwrite any existing file #13673

Closed
raboof opened this issue Dec 18, 2015 · 5 comments
Closed

os: document that os.Rename will overwrite any existing file #13673

raboof opened this issue Dec 18, 2015 · 5 comments

Comments

@raboof
Copy link

raboof commented Dec 18, 2015

TestRenameOverwriteDest suggests that on all OS'es except plan9, when the target path of os.Rename already exists, it will be replaced.

It might be nice to add that to the docs: for example on Windows it is not obvious (syscall_windows.go explicitly adds the MOVEFILE_REPLACE_EXISTING flag - there's no way to tell without either looking at the code or testing)

@ianlancetaylor
Copy link
Contributor

Seems like if we are going to document it we should make sure that Plan 9 behaves that way too.

@raboof
Copy link
Author

raboof commented Dec 21, 2015

Wait, I'm confused - https://github.com/golang/go/blob/master/src/syscall/syscall_windows.go#L423 does not look like it actually would overwrite the target file, while https://github.com/golang/go/blob/master/src/internal/syscall/windows/syscall_windows.go#L130 does.

@ianlancetaylor
Copy link
Contributor

os.Rename uses windows.Rename from internal/syscall/windows.

@rsc
Copy link
Contributor

rsc commented Jan 6, 2016

Filed #13844 for Plan 9 and will write docs.

@gopherbot
Copy link

CL https://golang.org/cl/18332 mentions this issue.

@rsc rsc closed this as completed in 5d8442a Jan 7, 2016
@golang golang locked and limited conversation to collaborators Jan 7, 2017
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

4 participants