duanlu0386 2018-01-09 17:10
浏览 229
已采纳

Golang是否有libfaketime替代品?

I want to automate some tests where I have to manipulate the system time to check for authentication behaviours of a program that is written in golang. According to this post, libfaketime does not work with golang. Is there another way that I can achieve what I want to do with libfaketime?

Here's a description of what libfaketime does from github.

libfaketime intercepts various system calls that programs use to retrieve the current date and time. It then reports modified (faked) dates and times (as specified by you, the user) to these programs. This means you can modify the system time a program sees without having to change the time system-wide.

  • 写回答

2条回答 默认 最新

  • doz15449 2018-01-09 17:33
    关注

    No, there is none.

    You need to use something like clockwork (see this for more) and explicitly pass "time" implementation around your code.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥15 对于这个复杂问题的解释说明
  • ¥50 三种调度算法报错 有实例
  • ¥15 关于#python#的问题,请各位专家解答!
  • ¥200 询问:python实现大地主题正反算的程序设计,有偿
  • ¥15 smptlib使用465端口发送邮件失败
  • ¥200 总是报错,能帮助用python实现程序实现高斯正反算吗?有偿
  • ¥15 对于squad数据集的基于bert模型的微调
  • ¥15 为什么我运行这个网络会出现以下报错?CRNN神经网络
  • ¥20 steam下载游戏占用内存
  • ¥15 CST保存项目时失败