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

runtime: please expose nanotime #16658

Closed
pi opened this issue Aug 10, 2016 · 3 comments

Comments

Projects
None yet
4 participants
@pi
Copy link

commented Aug 10, 2016

go version go1.7rc3 windows/amd64
There is no access to monotonic time in standard Go library, but there is private function runtime.nanotime. Please make it public (as System.nanoTime in Java) because time.Now is not monotonic and can be changed during probe (by user or by ntp server sync).

@ianlancetaylor ianlancetaylor changed the title Please expose runtime.nanotime runtime: please expose nanotime Aug 10, 2016

@ianlancetaylor

This comment has been minimized.

Copy link
Contributor

commented Aug 10, 2016

This seems reasonable to me but I think the question is whether it should be in the time package in the standard library or in some external repository.

@ianlancetaylor ianlancetaylor added this to the Go1.8 milestone Aug 10, 2016

@pi

This comment has been minimized.

Copy link
Author

commented Aug 10, 2016

time.Nanotime() is better to read but can lead to confusion of monotonic time and real time.
External package will require maintaining of two copies of identical code because nanotime is already implemented in runtime package.
I think runtime.Nanotime() if starting point is program start or os.Nanotime() if starting point is os boot.

@bradfitz

This comment has been minimized.

Copy link
Member

commented Aug 10, 2016

Dup of #12914

@bradfitz bradfitz closed this Aug 10, 2016

@golang golang locked and limited conversation to collaborators Aug 10, 2017

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
You can’t perform that action at this time.