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

fmt: %+v doesn't work for types external to package #8327

Closed
gopherbot opened this issue Jul 4, 2014 · 1 comment
Closed

fmt: %+v doesn't work for types external to package #8327

gopherbot opened this issue Jul 4, 2014 · 1 comment

Comments

@gopherbot
Copy link
Contributor

by stephen.searles@shipwire.com:

What does 'go version' print?

1.3

What steps reproduce the problem?
If possible, include a link to a program on play.golang.org.

http://play.golang.org/p/wEN2KnN4CM

What happened?

Only type declared in current package gets field names

What should have happened instead?

Either make the field names work for imported packages, or the documentation should have
made this behavior clear. Currently, it just says: "when printing structs, the plus
flag (%+v) adds field names".
@minux
Copy link
Member

minux commented Jul 4, 2014

Comment 1:

both *net/url.URL and image.Rect have String method, so %+v
will just call it to convert it to string.
This behavior is well documented.
http://play.golang.org/p/kLP4FCTl8U

Labels changed: added repo-main.

Status changed to WorkingAsIntended.

@golang golang locked and limited conversation to collaborators Jun 25, 2016
This issue was closed.
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

2 participants