-
-
Notifications
You must be signed in to change notification settings - Fork 1
Description
In the current implementation, all directories — and consequently, all packages — within the CWD are parsed. This, first of all, results in unnecessary work and, secondly, may introduce bugs. For example, if another subpackage defines a constant with the same prefix or a type with the same name, there is a risk of selecting the wrong type for values (as in merge #9) and/or adding extra elements to the enum.
go generate sets the environment variables GOPACKAGE and GOFILE for the package and file being processed, which can be used to filter packages. Additionally, in theory, it is possible to parse only the file specified in GOFILE, but this would remove the ability to “add” elements to an enum from other files within the same package — I’m not sure how necessary that is.
Additionally, when parsing values, it would be good to add a condition to check for a matching constant type, not just the presence of a specific prefix.