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, time: add API BuildTimestamp to report an application's build time #1

Closed
vipally opened this issue Dec 22, 2017 · 2 comments
Closed
Assignees
Labels

Comments

@vipally
Copy link
Owner

vipally commented Dec 22, 2017

refer golang#23175

Use build timestamp to distinguish different version of application binary is a common way in other languages.
eg: C has macros "__DATE__" and "__TIME__" to fetch compiler time.
But golang has no way to achive this feature nowadays.
I have made a patch to provide fllow API to achive it.

runtime.BuildTimestamp defines a buildtimestamp value which will be written by linker(cmd/link).

time.BuildTime() converts runtime.BuildTimestamp() to time.Time.
The expected usage of BuildTimestamp API is as follow:

func main() {
	println("hello world!")
	println("buildtimestamp:", runtime.BuildTimestamp())
	println("buildtime     :", time.BuildTime().String())
	// Output:
	// hello world!
	// buildtimestamp: 1513671919
	// buildtime     : 2017-12-19 16:25:19 +0800 CST
}

It will be my pleasure that if go team can accept this feature in go repository.
The branch

@vipally
Copy link
Owner Author

vipally commented Dec 22, 2017

This issue has been reject by offical
see golang#23175
So I provide my own go master branch to support some useful issues that official repository do not support

@vipally vipally self-assigned this Dec 22, 2017
@vipally vipally changed the title proposal: runtime, time: add API BuildTimestamp to report an application's build time runtime, time: add API BuildTimestamp to report an application's build time Dec 22, 2017
vipally added a commit that referenced this issue Dec 23, 2017
…d time (#6)

#1 runtime, time: add API BuildTimestamp to report an application's build time
@vipally
Copy link
Owner Author

vipally commented Dec 23, 2017

runtime.UnixNow
runtime.UnixNowNano
do not include in this release

@vipally vipally closed this as completed Dec 23, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant