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
Closed

runtime: please expose nanotime #16658

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

Comments

@pi
Copy link

pi 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
Copy link
Contributor

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
Copy link
Author

pi 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
Copy link
Contributor

Dup of #12914

@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.
Projects
None yet
Development

No branches or pull requests

4 participants