diff --git a/lintcmd/cmd.go b/lintcmd/cmd.go index eace8bc0..069b276e 100644 --- a/lintcmd/cmd.go +++ b/lintcmd/cmd.go @@ -271,9 +271,9 @@ func decodeGob(br io.ByteReader) ([]run, error) { return runs, nil } -// Run runs all registered analyzers and reports their findings. -// It always calls os.Exit and does not return. -func (cmd *Command) Run() { +// Execute runs all registered analyzers and reports their findings. +// The status code returned can be used for os.Exit(cmd.Execute()). +func (cmd *Command) Execute() int { // Set up profiling and tracing if path := cmd.flags.debugCpuprofile; path != "" { f, err := os.Create(path) @@ -332,8 +332,13 @@ func (cmd *Command) Run() { trace.Stop() } - // Exit with appropriate status - os.Exit(exit) + return exit +} + +// Run runs all registered analyzers and reports their findings. +// It always calls os.Exit and does not return. +func (cmd *Command) Run() { + os.Exit(cmd.Execute()) } func (cmd *Command) analyzersAsSlice() []*lint.Analyzer {