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: OpenFile can not set mode #10521

Closed
galric opened this issue Apr 21, 2015 · 2 comments
Closed

os: OpenFile can not set mode #10521

galric opened this issue Apr 21, 2015 · 2 comments

Comments

@galric
Copy link

galric commented Apr 21, 2015

var mode os.FileMode = 0666
os.OpenFile("g2", os.O_WRONLY|os.O_TRUNC|os.O_CREATE, mode)

create file with mode
-rw-rw-r-- 1 admin admin 0 Apr 21 18:25 g2

not
-rw-rw-rw- 1 admin admin 0 Apr 21 18:24 g2

miss w

At go version go1.4.1 linux/amd64

@mattn
Copy link
Member

mattn commented Apr 21, 2015

Probably, your umask is 0022.
http://man7.org/linux/man-pages/man2/open.2.html

The effective permissions are modified by the process's umask in the usual way: The permissions of the created file are (mode & ~umask).

@galric
Copy link
Author

galric commented Apr 21, 2015

Thank you, you are right

@galric galric closed this as completed Apr 21, 2015
@golang golang locked and limited conversation to collaborators Jun 25, 2016
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

3 participants