import ( "github.com/cockroachdb/cockroach/util/hlc" "fmt" ) func main() { now := hlc.Clock{}.Now() fmt.Println(now) }
import ( "github.com/cockroachdb/cockroach/util/hlc" "time" ) func main() { clock := hlc.NewClock(time.Now().UnixNano()) now := clock.Now() println(now.String()) }In this example, we create a new instance of the Clock struct with an initial time value obtained from the UnixNano method of the time package. We then call the Now method to retrieve the current HLC timestamp, which we convert to a string and print to the console.