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: '+' and '#' flags not passed to fmt.Formatter when using 'v' verb on composite values. #8835

Closed
ChrisHines opened this issue Sep 29, 2014 · 5 comments
Milestone

Comments

@ChrisHines
Copy link
Contributor

@ChrisHines ChrisHines commented Sep 29, 2014

What does 'go version' print?

go version go1.3.1 windows/amd64

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

1. Run http://play.golang.org/p/mtWFU1M8-G

What happened?

Five tests fail.

What should have happened instead?

No tests fail.

Please provide any additional information below.

When printing a composite type containing values that implement fmt.Formatter and using
format strings such as "%+v" and "%#v", the type's Format(f
fmt.State, c rune) method is called such that f.Flag('+') == false and f.Flag('#') ==
false.

I couldn't find any tests cases that exercise this combination of features and the
documentation seems ambiguous on this particular usage. The package documentation only
gives special exemptions to %T and %p with regard to implementing fmt.Formatter. It
would seem when printing a composite structure that did not itself implement
fmt.Formatter, but contained values that did, that a "%+v" or a
"%#v" format should apply to each contained value just as a "%+q" or
a "%#x" does.

Note that when printing individual values the '+' and '#' flags *are* discoverable, it
is only when the value is reached indirectly through a composite value that the '+' and
'#' flags are not passed on (and only for the 'v' verb).
@ianlancetaylor
Copy link
Contributor

@ianlancetaylor ianlancetaylor commented Sep 29, 2014

Comment 1:

Labels changed: added repo-main, release-go1.5.

@gopherbot
Copy link

@gopherbot gopherbot commented Oct 1, 2014

Comment 2:

CL https://golang.org/cl/146650043 mentions this issue.
@robpike
Copy link
Contributor

@robpike robpike commented Oct 2, 2014

Comment 3:

This issue was updated by revision 7c8e057.

LGTM=iant
R=golang-codereviews, iant
CC=golang-codereviews
https://golang.org/cl/146650043
@gopherbot
Copy link

@gopherbot gopherbot commented Oct 3, 2014

Comment 4:

CL https://golang.org/cl/154820043 mentions this issue.
@robpike
Copy link
Contributor

@robpike robpike commented Oct 3, 2014

Comment 5:

This issue was closed by revision a224245.

Status changed to Fixed.

@bradfitz bradfitz modified the milestone: Go1.5 Dec 16, 2014
@bradfitz bradfitz removed the release-go1.5 label Dec 16, 2014
@golang golang locked and limited conversation to collaborators Jun 25, 2016
wheatman added a commit to wheatman/go-akaros that referenced this issue Jun 25, 2018
Apply a similar transformation to %+v that we did to %#v, making it
a top-level setting separate from the + flag itself. This fixes the
appearance of flags in Formatters and cleans up the code too,
probably making it a little faster.

Fixes golang#8835.

LGTM=iant
R=golang-codereviews, iant
CC=golang-codereviews
https://golang.org/cl/154820043
wheatman added a commit to wheatman/go-akaros that referenced this issue Jun 26, 2018
Apply a similar transformation to %+v that we did to %#v, making it
a top-level setting separate from the + flag itself. This fixes the
appearance of flags in Formatters and cleans up the code too,
probably making it a little faster.

Fixes golang#8835.

LGTM=iant
R=golang-codereviews, iant
CC=golang-codereviews
https://golang.org/cl/154820043
wheatman added a commit to wheatman/go-akaros that referenced this issue Jul 9, 2018
Apply a similar transformation to %+v that we did to %#v, making it
a top-level setting separate from the + flag itself. This fixes the
appearance of flags in Formatters and cleans up the code too,
probably making it a little faster.

Fixes golang#8835.

LGTM=iant
R=golang-codereviews, iant
CC=golang-codereviews
https://golang.org/cl/154820043
wheatman added a commit to wheatman/go-akaros that referenced this issue Jul 30, 2018
Apply a similar transformation to %+v that we did to %#v, making it
a top-level setting separate from the + flag itself. This fixes the
appearance of flags in Formatters and cleans up the code too,
probably making it a little faster.

Fixes golang#8835.

LGTM=iant
R=golang-codereviews, iant
CC=golang-codereviews
https://golang.org/cl/154820043
This issue was closed.
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

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