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
The use of json:"..." as a tag in the comment is too generic. It may conflict with casual comments elsewhere in the code (in const or var). Consider renaming to enum:"...".
Note that once #24 get fixed, such conflicts should not happen, since this would be confined to the designated type; Nevertheless, IMO enum:"..." would still be more precise choice.
For example:
package main
typeEnumuint8//go:generate go-enum-encoding -type=Enumconst (
PlainEnum=iota+1// json:"one_plain"
)
var (
Variableint// json:"something"
)
The text was updated successfully, but these errors were encountered:
json is intentional. we are relying on the same tag that people are already familiar with.
this is natural choice as it follows notation how people are declaring field names for JSON for structs. this reduces cognitive load and allows easy learning. this choice also emphasises, that our concern here is encoding/decoding, and nothing else, which makes limited scope of this tool, which is also beneficial. in fact, I would rather raise proposal to official Go language to include this as official Go language notation.
conflicts with other json tags
best I know, json comment tags can not be used in const nor var declaration. the only place standard Go (and any 3rd party packages I know) are using json tags so far are in struct declaration. this AST tool scans json tags only for const and var declarations. thus no conflicts should happen.
The use of
json:"..."
as a tag in the comment is too generic. It may conflict with casual comments elsewhere in the code (in const or var). Consider renaming toenum:"..."
.Note that once #24 get fixed, such conflicts should not happen, since this would be confined to the designated type; Nevertheless, IMO
enum:"..."
would still be more precise choice.For example:
The text was updated successfully, but these errors were encountered: