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

struct with embedded time.Time prints incorrectly #18480

Closed
jba opened this issue Dec 30, 2016 · 1 comment
Closed

struct with embedded time.Time prints incorrectly #18480

jba opened this issue Dec 30, 2016 · 1 comment

Comments

@jba
Copy link
Contributor

jba commented Dec 30, 2016

If you embed time.Time in a struct, %+v prints it out as just a time, not a struct.

What version of Go are you using (go version)?

1.7.4

What operating system and processor architecture are you using (go env)?

playground

What did you do?

https://play.golang.org/p/r-zlQzU67e

What did you expect to see?

{X:0 Time:0001-01-01 00:00:00 +0000 UTC}

What did you see instead?

0001-01-01 00:00:00 +0000 UTC

@cespare
Copy link
Contributor

cespare commented Dec 30, 2016

%v and %+v both call String(), if defined, and time.Time has a String method that's getting invoked here because you used struct embedding. Working as intended.

@minux minux closed this as completed Dec 31, 2016
@golang golang locked and limited conversation to collaborators Dec 31, 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