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

Why not define this layout as a standard const value? #42012

Closed
yerstd opened this issue Oct 16, 2020 · 4 comments
Closed

Why not define this layout as a standard const value? #42012

yerstd opened this issue Oct 16, 2020 · 4 comments

Comments

@yerstd
Copy link

yerstd commented Oct 16, 2020

s := t.Format("2006-01-02 15:04:05.999999999 -0700 MST")

@yerstd yerstd changed the title Why not make this layout as a standard const variable? Why not define this layout as a standard const value? Oct 16, 2020
@mvdan
Copy link
Member

mvdan commented Oct 16, 2020

Read the docs:

// The returned string is meant for debugging; for a stable serialized
// representation, use t.MarshalText, t.MarshalBinary, or t.Format
// with an explicit format string.

The Go project doesn't use the issue tracker for questions. See https://golang.org/wiki/Questions.

@mvdan mvdan closed this as completed Oct 16, 2020
@yerstd
Copy link
Author

yerstd commented Oct 20, 2020

@mvdan I think it's inappropriate because json.Marshal and many other methods use this function for time.Time to convert a string. So I demand to define this layout as a const valiable. Also, this annotation here is not that good.

@mvdan
Copy link
Member

mvdan commented Oct 20, 2020

json.Marshal and many other methods use this function for time.Time to convert a string

That doesn't seem to be true: https://golang.org/src/time/time.go?s=38148:38191#L1230

Again, I would suggest that you use the forums for these questions before filing bugs.

So I demand

That comes off a bit aggressive, but I assume you didn't mean it that way.

@yerstd
Copy link
Author

yerstd commented Oct 20, 2020

No,I mean strongly suggest,not that way.The json.marshal may be not a correct example,I mean we use time.Time.String very frequently,so make this layout as a constant may be very pretty or make the string function use time.RFC3339Nano layout would also be better(the second way may be not compatible),otherwise we should define the same layout ourself and it's duplicated.

@golang golang locked and limited conversation to collaborators Oct 20, 2021
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

3 participants