Skip to content

Commit c0799f7

Browse files
committed
os: document that Rename is not atomic on non-Unix platforms
Windows provides no reliable way to rename files atomically. The Plan 9 implementation of os.Rename performs a deletion if the target exists. Change-Id: Ife5f9c97b21f48c11e300cd76d8c7f715db09fd4 Reviewed-on: https://go-review.googlesource.com/c/go/+/462395 Auto-Submit: Alan Donovan <[email protected]> Reviewed-by: Ian Lance Taylor <[email protected]> TryBot-Result: Gopher Robot <[email protected]> Run-TryBot: Alan Donovan <[email protected]> Reviewed-by: Bryan Mills <[email protected]>
1 parent d74c31f commit c0799f7

File tree

1 file changed

+1
-0
lines changed

1 file changed

+1
-0
lines changed

src/os/file.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -338,6 +338,7 @@ var lstat = Lstat
338338
// Rename renames (moves) oldpath to newpath.
339339
// If newpath already exists and is not a directory, Rename replaces it.
340340
// OS-specific restrictions may apply when oldpath and newpath are in different directories.
341+
// Even within the same directory, on non-Unix platforms Rename is not an atomic operation.
341342
// If there is an error, it will be of type *LinkError.
342343
func Rename(oldpath, newpath string) error {
343344
return rename(oldpath, newpath)

0 commit comments

Comments
 (0)