Description
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
type systemKind int
const (
Windows systemKind = iota
MacOS
Linux
Android
Ios
)
$ stringer -type systemKind ./test_data/
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.
const (
Windows systemKind = iota
MacOS // `str:"macOS"`
Linux // `long:"the best system"`
Android
Ios // `str:"iOS"`
)
So the method (i systemKind) String()
would get WindowsmacOSLinuxAndroidiOS
.
And it would add a second method, e.g. (systemKind) LongString()
where it would return "the best system" for the value Linux
.