You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When constant values of a type are declared in separate files, it's difficult to detect whether one has assigned the same value to more than one name. The stringer command would be an ideal place to detect this, and issue at least a warning, or even fail (since one could argue that the String method is not well-defined for that value).
The text was updated successfully, but these errors were encountered:
It's reasonable to have multiple values for a given constant, as the example in the command documentation states:
For example, given this snippet,
package painkiller
type Pill int
const (
Placebo Pill = iota
Aspirin
Ibuprofen
Paracetamol
Acetaminophen = Paracetamol
)
I think it would be a mistake, a category error, to have stringer become a diagnostic and analysis tool. It blurs its purpose, which is just to make it easy to print names of constants, not to check the correctness of your program.
If you want this sort of constant checking, that should be a separate tool that runs independent of stringer.
When constant values of a type are declared in separate files, it's difficult to detect whether one has assigned the same value to more than one name. The stringer command would be an ideal place to detect this, and issue at least a warning, or even fail (since one could argue that the String method is not well-defined for that value).
The text was updated successfully, but these errors were encountered: