package lintcmd
import "honnef.co/go/tools/lintcmd"
Package lintcmd implements the frontend of an analysis runner. It serves as the entry-point for the staticcheck command, and can also be used to implement custom linters that behave like staticcheck.
Index ¶
- type Command
- func NewCommand(name string) *Command
- func (cmd *Command) AddAnalyzers(as ...*lint.Analyzer)
- func (cmd *Command) AddBareAnalyzers(as ...*analysis.Analyzer)
- func (cmd *Command) FlagSet() *flag.FlagSet
- func (cmd *Command) ParseFlags(args []string)
- func (cmd *Command) Run()
- func (cmd *Command) SetVersion(human, machine string)
Types ¶
type Command ¶
type Command struct {
// contains filtered or unexported fields
}
Command represents a linter command line tool.
func NewCommand ¶
NewCommand returns a new Command.
func (*Command) AddAnalyzers ¶
AddAnalyzers adds analyzers to the command. These are lint.Analyzer analyzers, which wrap analysis.Analyzer analyzers, bundling them with structured documentation.
To add analysis.Analyzer analyzers without providing structured documentation, use AddBareAnalyzers.
func (*Command) AddBareAnalyzers ¶
AddBareAnalyzers adds bare analyzers to the command.
func (*Command) FlagSet ¶
FlagSet returns the command's flag set. This can be used to add additional command line arguments.
func (*Command) ParseFlags ¶
ParseFlags parses command line flags. It must be called before calling Run. After calling ParseFlags, the values of flags can be accessed.
Example:
cmd.ParseFlags(os.Args[1:])
func (*Command) Run ¶
func (cmd *Command) Run()
Run runs all registered analyzers and reports their findings. It always calls os.Exit and does not return.
func (*Command) SetVersion ¶
SetVersion sets the command's version. It is divided into a human part and a machine part. For example, Staticcheck 2020.2.1 had the human version "2020.2.1" and the machine version "v0.1.1". If you only use Semver, you can set both parts to the same value.
Calling this method is optional. Both versions default to "devel", and we'll attempt to deduce more version information from the Go module.
Source Files ¶
cmd.go config.go directives.go format.go lint.go sarif.go stats_bsd.go
Directories ¶
Path | Synopsis |
---|---|
lintcmd/cache | Package cache implements a build artifact cache. |
lintcmd/runner | Package runner implements a go/analysis runner. |
lintcmd/version |
- Version
- v0.4.0
- Published
- Feb 3, 2023
- Platform
- darwin/amd64
- Imports
- 40 packages
- Last checked
- 5 minutes ago –
Tools for package owners.