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
wk30 opened this issue Oct 16, 2020 · 4 comments
Closed

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

wk30 opened this issue Oct 16, 2020 · 4 comments

Comments

@wk30
Copy link

@wk30 wk30 commented Oct 16, 2020

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

@wk30 wk30 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 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 Oct 16, 2020
@wk30
Copy link
Author

@wk30 wk30 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 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.

@wk30
Copy link
Author

@wk30 wk30 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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
2 participants
You can’t perform that action at this time.