[ACCEPTED]-Reading default FileMode when using os.O_CREATE-umask
Accepted answer
It already works like you want it.
Just use 4 "0666" and the umask will be applied.
f, err := os.OpenFile(fpath, os.O_CREATE|os.O_WRONLY, 0666)
For 3 me with umask 0022
I get:
$ go run x.go ; ls -l filename
-rw-r--r-- 1 ask wheel 0 May 24 00:18 filename
Use 0660 (for example) if 2 you always want the file to be unreadable 1 by "other", no matter the umask.
Source:
stackoverflow.com
More Related questions
Cookie Warning
We use cookies to improve the performance of the site. By staying on our site, you agree to the terms of use of cookies.