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

c# - Unity IoC Lifetime per HttpRequest for UserStore -

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

I am trying to solve the error message 'incompatible ranks 0 and 1 in assignment' in a fortran 95 program. -