Home > OS >  Golang os.FileMode corresponding to drwxrwxr-x?
Golang os.FileMode corresponding to drwxrwxr-x?

Time:11-04

Which os.FileMode values should I provide to os.Mkdir as an argument to have a permission corresponding to drwxrwxr-x?

CodePudding user response:

Daniel Farrell's answer covers the literal settings for modes, but if you're working on a Unix-like system, there are two other important points:

  • For most cases (most files), you should just use 0666.
  • For most of the remaining cases (most directories), you should just use 0777.

Certain Go code checkers complain about this, but they're just wrong.

  •  Tags:  
  • go
  • Related