https://github.com/asppj/gofaketime
通过monkey patch的方式修复libfaketime不适用于golang的问题;
https://github.com/asppj/gofaketime
Last synced: 2 months ago
JSON representation
通过monkey patch的方式修复libfaketime不适用于golang的问题;
- Host: GitHub
- URL: https://github.com/asppj/gofaketime
- Owner: asppj
- License: mit
- Created: 2022-01-14T06:38:48.000Z (over 3 years ago)
- Default Branch: main
- Last Pushed: 2022-03-28T01:55:01.000Z (over 3 years ago)
- Last Synced: 2025-03-30T11:51:09.279Z (3 months ago)
- Language: Go
- Size: 22.5 KB
- Stars: 7
- Watchers: 3
- Forks: 3
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# gofaketime
通过monkey patch的方式修复libfaketime不适用于golang的问题;### 前提
[libfaketime](https://github.com/wolfcw/libfaketime)### 注意事项
1. 不能在权限管控严格的操作系统运行;如:macOS;
2. 需要结合libfaketime使用
3. 需要开启cgo功能;```golang
package mainimport (
"time""github.com/asppj/gofaketime"
)func main() {
println("系统时间", time.Now().Format(time.RFC3339))
println("启动补丁>>>")
faker := gofaketime.NewFakeTime()
defer faker.Close()
println("修改后的时间", time.Now().Format(time.RFC3339))
println("运行完成")
}
```### linux示例
