Skip to content

x/tools/go/analysis/singlechecker: don't use flag.CommandLine #30231

Closed
@mvdan

Description

@mvdan

Using package flag's global flagset is convenient, but shouldn't happen in packages like singlechecker and unitchecker which may be used in many different ways.

In particular, lots of packages like to abuse the same global flagset, such as testing and net/http/pprof, among many others outside the standard library.

Granted that a linter should generally not import those packages to begin with. But sometimes you just can't control your dependencies. And there's the case which I hit - I'm running my tool as part of a test, so testing is in the build import graph. So one of my tests is failing as the testing flags are getting mixed into the usage output.

I presume we could have unitchecker export a global flagset, and singlechecker could use it too.

Metadata

Metadata

Assignees

No one assigned

    Labels

    FrozenDueToAgeNeedsInvestigationSomeone must examine and confirm this is a valid issue and not a duplicate of an existing one.

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions