From: Alan Donovan Date: Tue, 17 Jan 2023 16:30:48 +0000 (-0500) Subject: os: document that Rename is not atomic on non-Unix platforms X-Git-Tag: go1.20~9^2~1 X-Git-Url: http://www.git.cypherpunks.su/?a=commitdiff_plain;h=c0799f7015e6cae37c21294bb94f56050fda5f4e;p=gostls13.git 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 Reviewed-by: Ian Lance Taylor TryBot-Result: Gopher Robot Run-TryBot: Alan Donovan Reviewed-by: Bryan Mills --- diff --git a/src/os/file.go b/src/os/file.go index 6781b54da0..3d71ac068e 100644 --- a/src/os/file.go +++ b/src/os/file.go @@ -338,6 +338,7 @@ var lstat = Lstat // Rename renames (moves) oldpath to newpath. // If newpath already exists and is not a directory, Rename replaces it. // OS-specific restrictions may apply when oldpath and newpath are in different directories. +// Even within the same directory, on non-Unix platforms Rename is not an atomic operation. // If there is an error, it will be of type *LinkError. func Rename(oldpath, newpath string) error { return rename(oldpath, newpath)