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: opening an existing file with O_CREATE|O_TRUNC and permission 0 changes file to be read-only on Windows [1.14 backport] #39158

gopherbot opened this issue May 20, 2020 · 2 comments


Copy link

@gopherbot gopherbot commented May 20, 2020

@ianlancetaylor requested issue #38225 to be considered for backport to the next 1.14 minor release.

@gopherbot Please open a backport to 1.14. This is a regression that was introduced in 1.14.

Copy link

@gopherbot gopherbot commented May 20, 2020

Change mentions this issue: [release-branch.go1.14] syscall: preserve Windows file permissions for O_CREAT|O_TRUNC

Copy link

@gopherbot gopherbot commented May 23, 2020

Closed by merging f758dab to release-branch.go1.14.

@gopherbot gopherbot closed this May 23, 2020
gopherbot pushed a commit that referenced this issue May 23, 2020

On Windows, calling syscall.Open(file, O_CREAT|O_TRUNC, 0) for a file
that already exists would change the file to be read-only.
That is not how the Unix syscall.Open behaves, so avoid it on
Windows by calling CreateFile twice if necessary.

For #38225
Fixes #39158

Change-Id: I70097fca8863df427cc8a97b9376a9ffc69c6318
Run-TryBot: Ian Lance Taylor <>
TryBot-Result: Gobot Gobot <>
Reviewed-by: Alex Brainman <>
(cherry picked from commit 567556d)
Reviewed-by: Emmanuel Odeke <>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
2 participants
You can’t perform that action at this time.