-
Notifications
You must be signed in to change notification settings - Fork 18k
x/tools/cmd/stringer: document -linecomment in 'go doc stringer' #29867
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
Comments
Duplicate of #20483. See the solution there, which has been implemented for over a year. |
Sorry, but it doesn't solve the issue to generate a second method with other string. |
Sure. You're mixing two proposals, though. Stringer generates exactly one method per type, and extra methods have been rejected in the past. For example, see #23535. |
The stringer tool is intentionally simple, and making it more complicated will, well, make it more complicated. You can certainly use it as the basis for a tool that does what you want. |
@griesemer points out there is an undocumented |
Marked declined but we should absolutely document this useful feature. |
Change https://golang.org/cl/191309 mentions this issue: |
Fixes golang/go#29867 Change-Id: I0328a97c9e2ee4b42a0b0d2b9948bf69a6ee3322 Reviewed-on: https://go-review.googlesource.com/c/tools/+/191309 Reviewed-by: Rob Pike <r@golang.org>
This proposal is for that the 'stringer' tool gets flexibility at return strings, because the names that it returns are cased as they are in the values defined.
Problem
The names that it generates are
WindowsMacOSLinuxAndroidIos
.But sometimes you want show the name of other way, e.g.
"macOS" for "MacOS" or "iOS" for "Ios"
So, the name given to define a constant has not to be the name wanted to be showed into a string.
Also, I would want to get other funcion name to get the string given into a tag string.
Proposal
Using a tag string like
str
to generate an alternative name, and with an optional tag name (e.g.long
) to generate a funcion where return the string.So the method
(i systemKind) String()
would getWindowsmacOSLinuxAndroidiOS
.And it would add a second method, e.g.
(systemKind) LongString()
where it would return "the best system" for the value
Linux
.The text was updated successfully, but these errors were encountered: