create a directory with normal permission in go -


how can create directory normal permissions (say 0700 in octal notation) os.mkdir method. did not manage find how set perm value correctly.

you can use octal notation directly:

os.mkdir("dirname", 0700) 

from documentation filemode:

the 9 least-significant bits standard unix rwxrwxrwx permissions

the mode bits defined may use normal octal notation chmod. however, must prefix 0 tell go octal literal.

also, remember 4th number doesn't exist in chmod. chmod, 1700 set sticky bit. in go, need set bit defined in os lib doing like: 0700 | os.modesticky


Comments

Popular posts from this blog

What can cause "Required Package 'IndyCore' not found" when compiling a Delphi 2010 project? -

Change the color of an oval at click in Java AWT -