Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to faketime Go Lang time.now() calls #481

Open
sivachaitanya opened this issue Dec 4, 2024 · 0 comments
Open

How to faketime Go Lang time.now() calls #481

sivachaitanya opened this issue Dec 4, 2024 · 0 comments

Comments

@sivachaitanya
Copy link

sivachaitanya commented Dec 4, 2024

Thanks for an awesome tool, I have followed all the documentation instructions and was able to create /etc/ld.so.preload and /etc/faketimerc files assuming to fake all system wide calls. Inside faketimerc I have text -300d, and i have set the below env variables

export FAKETIME_XRESET=1
export FAKETIME_NO_CACHE=1
export LD_PRELOAD=/usr/local/src/libfaketime/src/libfaketime.so.1

before setting LD_PRELOAD date was current host time and after setting LD_PRELOAD it shows the current date - 300d. My env is currently Kubernetes pod on AKS and i dont have root privileges, I am trying to run a Golang program to see if the date changes are happening with time.now() but still it shows current date, can you let me know how to have golang time.now() take faketimerc date changes ?

golang time.now() code -

package main
 
import (
    "fmt"
    "time"
)
 
func main() {
 
    
    var d  = time.Now()
 
    fmt.Println(d)
 

}

golanf time.now() source - https://github.com/golang/go/blob/master/src/time/time.go

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant