Versions Compared
compared with
Key
- This line was added.
- This line was removed.
- Formatting was changed.
gfile
模块是对文件操作的进一步封装,提供了常用的,简易的API来操作底层文件,隐藏了复杂的底层实现细节。
使用方式:
import "github.com/gogf/gf/os/gfile"
接口文档:
https://godoc.org/github.com/gogf/gf/os/gfile
修改时间
MTime
- 说明:获取路径修改时间
示例:
Code Block language go func ExampleMTime() { // 获取路径修改时间 t := gfile.MTime(gfile.TempDir()) fmt.Println(t) // May Output: // 2021-11-02 15:18:43.901141 +0800 CST }
ExampleMTimestamp
- 说明:获取路径修改时间戳(秒)
示例:
Code Block language go func ExampleMTimestamp() { // 获取路径修改时间戳(秒) t := gfile.MTimestamp(gfile.TempDir()) fmt.Println(t) // May Output: // 1635838398 }
ExampleMTimestampMilli
- 说明:获取路径修改时间戳(毫秒)
示例:
Code Block language go func ExampleMTimestampMilli() { // 获取路径修改时间戳(毫秒) t := gfile.MTimestampMilli(gfile.TempDir()) fmt.Println(t) // May Output: // 1635838529330 }
Panel | ||
---|---|---|
| ||
|