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

Go 1.14 makes the file read-only using ioutil.writefile ("d:/test.txt", []byte("data"), os.modeappend) #39125

Closed
xunxinyuan opened this issue May 18, 2020 · 3 comments
Labels
FrozenDueToAge WaitingForInfo Issue is not actionable because of missing required information, which needs to be provided.

Comments

@xunxinyuan
Copy link

What version of Go are you using (go version)?

$ go version
1.14
1.14.3

Does this issue reproduce with the latest release?

yes

What operating system and processor architecture are you using (go env)?

go env Output
$ go env
set GO111MODULE=auto
set GOARCH=amd64
set GOBIN=
set GOCACHE=C:\Users\Administrator\AppData\Local\go-build
set GOENV=C:\Users\Administrator\AppData\Roaming\go\env
set GOEXE=.exe
set GOFLAGS=
set GOHOSTARCH=amd64
set GOHOSTOS=windows
set GOINSECURE=
set GONOPROXY=
set GONOSUMDB=
set GOOS=windows
set GOPATH=C:\Users\Administrator\go
set GOPRIVATE=
set GOPROXY=https://goproxy.cn,direct
set GOROOT=D:\Develop\Go
set GOSUMDB=sum.golang.org
set GOTMPDIR=
set GOTOOLDIR=D:\Develop\Go\pkg\tool\windows_amd64
set GCCGO=gccgo
set AR=ar
set CC=gcc
set CXX=g++
set CGO_ENABLED=1
set GOMOD=
set CGO_CFLAGS=-g -O2
set CGO_CPPFLAGS=
set CGO_CXXFLAGS=-g -O2
set CGO_FFLAGS=-g -O2
set CGO_LDFLAGS=-g -O2
set PKG_CONFIG=pkg-config
set GOGCCFLAGS=-m64 -mthreads -fmessage-length=0 -fdebug-prefix-map=C:\Users\ADMINI~1\AppData\Local\Temp\go-build038315006=/tmp/go-build -gno-record-gcc-switches

What did you do?

Go 1.12 And 1.13 is OK

What did you expect to see?

Do not modify file properties

What did you see instead?

Go 1.14.x makes the file read-only using ioutil.writefile ("d:/test.txt", []byte("data"), os.modeappend)
Go 1.12 & 1.13 is OK
OS : Windows10

@martisch
Copy link
Contributor

What is the full program?

func main() {
   ioutil.WriteFile("d:/test.txt", []byte("data")
}

Does the file exist before? With which permissions?

@martisch martisch added the WaitingForInfo Issue is not actionable because of missing required information, which needs to be provided. label May 18, 2020
@bcmills
Copy link
Contributor

bcmills commented May 18, 2020

Per https://golang.org/doc/go1.14#windows:

On Windows, creating a file via os.OpenFile with the os.O_CREATE flag, or via syscall.Open with the syscall.O_CREAT flag, will now create the file as read-only if the bit 0o200 (owner write permission) is not set in the permission argument. This makes the behavior on Windows more like that on Unix systems.

os.ModeAppend does not set any permission bits, so you are requesting a file that cannot be read, written, or executed, and ioutil.WriteFile is giving you as close to that as it can on Windows.

@bcmills bcmills closed this as completed May 18, 2020
@alexbrainman
Copy link
Member

Dup of #38225 ?

Alex

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
FrozenDueToAge WaitingForInfo Issue is not actionable because of missing required information, which needs to be provided.
Projects
None yet
Development

No branches or pull requests

5 participants