gofaketime

package module
v0.0.0-...-8abcf4c Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 1, 2022 License: MIT Imports: 4 Imported by: 0

README

gofaketime

通过monkey patch的方式修复libfaketime不适用于golang的问题;

前提

libfaketime

注意事项
  1. 不能在权限管控严格的操作系统运行;如:macOS;
  2. 需要结合libfaketime使用
  3. 需要开启cgo功能;
package main

import (
	"time"

	"github.com/td1126/gofaketime"
)

func main() {
	println("系统时间", time.Now().Format(time.RFC3339))
	println("启动补丁>>>")
	faker := gofaketime.NewFakeTime()
	defer faker.Close()
	println("修改后的时间", time.Now().Format(time.RFC3339))
	println("运行完成")
}
linux示例

img

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Close

func Close()

func Init

func Init()

Types

type FakeTime

type FakeTime struct {
	// contains filtered or unexported fields
}

func NewFakeTime

func NewFakeTime() *FakeTime

func (*FakeTime) Close

func (f *FakeTime) Close()

func (*FakeTime) Restore

func (f *FakeTime) Restore()

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL