在linux上想获取文件的元信息,我们需要使用系统调用lstat或者stat. 在golang的os包里已经把stat封装成了Stat函数,使用它比使用syscall要方便不少. 这是os.Stat的原型: func Stat(name string) (FileInfo, error) Stat returns a FileInfo describing the named file. If there is an error, it will be of type *PathError. 返
文件的时间属性的概念 上图第7-9是时间,默认是ctime(文件修改时间),有三种时间属性: modify time mtime (文件内容被修改的时间) change time ctime (文件属性被改变的时间) access time atime (被访问的时间) 注意:以上的时间均为文件最近/最后一次的时间节点. 文件的时间属性的格式化 ls -l --time-style=long-iso ls -l --t