Skip to content

Limit Parsing to Target Package to Avoid Unnecessary Work and Potential Bugs #10

@codemageddon

Description

@codemageddon

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions