]> Cypherpunks repositories - gostls13.git/commit
cmd/go: use os.Rename to move files on Windows
authorqmuntal <quimmuntal@gmail.com>
Tue, 29 Jul 2025 11:15:57 +0000 (13:15 +0200)
committerQuim Muntal <quimmuntal@gmail.com>
Fri, 1 Aug 2025 16:04:50 +0000 (09:04 -0700)
commit336931a4ca7172d4a21097b2b9a143a1c8df37f0
treef361710615942d245b1ef7b130470c2ad5168d39
parenteef5f8d93016147718afba8a05282d2ba7332c51
cmd/go: use os.Rename to move files on Windows

The Go toolchain has been copying files instead of moving them on
Windows since CL 72910. It did this because os.Rename doesn't respect
the destination directory ACL permissions, and we want to honor them.

The drawback is that copying files is slower than moving them.

This CL reintroduces the use of os.Rename, but it also sets the
destination file's ACL to inherit the permissions from the
destination directory.

On my computer this change speeds up a simple "go build" (with warm
cache) by 1 second, going from 3 seconds to 2 seconds.

Updates #22343

Change-Id: I65b2b6f301e9e18bf2588959764eb06b9a01dfa2
Reviewed-on: https://go-review.googlesource.com/c/go/+/691255
Reviewed-by: Mark Freeman <mark@golang.org>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Damien Neil <dneil@google.com>
src/cmd/go/internal/work/shell.go
src/cmd/go/internal/work/shell_nonwindows.go [new file with mode: 0644]
src/cmd/go/internal/work/shell_windows.go [new file with mode: 0644]
src/internal/syscall/windows/security_windows.go
src/internal/syscall/windows/types_windows.go
src/internal/syscall/windows/zsyscall_windows.go