Skip to content

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

Open
@sivachaitanya

Description

@sivachaitanya

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions