这个问题在这里已经有了答案:
How to properly instantiate os.FileMode
(2 个回答)
2年前关闭。
我关注 this简单的 go web app 教程,遇到了这个方法:
func (p *Page) save() error {
filename := p.Title + ".txt"
return ioutil.WriteFile(filename, p.Body, 0600)
}
关于值(value)
0600
它说:The octal integer literal 0600, passed as the third parameter to WriteFile, indicates that the file should be created with read-write permissions for the current user only. (See the Unix man page open(2) for details.)
这些值是否存储在任何地方,可能在
os
或 ioutil
包装为某种具有有意义名称的常量/枚举类型值?或者我们是否应该记住每个值的含义(或实现我们自己的命名常量)?
最佳答案
这些是 unix 文件系统权限的标准值。
三位数对应:
各个值由以下位或一起组成:
在
0600
例如,我们有:0
: 表示八进制表示6
: write | read
用户 0
: 无组 0
: 没有其他的更多关于 wikipedia
关于go - ioutil.WriteFile 文件模式/权限常量是否存储在任何地方?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/61682796/