❯ mage checkallverboselint # please see the example code for sample how this is executed in verbose mode
INFO [config_reader] Config search paths: [./ /Users/tomi/Code/golangci-mage-sample /Users/tomi/Code /Users/tomi /Users /]
INFO [config_reader] Used config file .golangci.yml
INFO [lintersdb] Active 6 linters: [errcheck gosimple govet ineffassign staticcheck unused]
INFO [loader] Go packages loading at mode 575 (compiled_files|deps|files|name|exports_file|imports|types_sizes) took 152.774375ms
INFO [runner/filename_unadjuster] Pre-built 0 adjustments in 936.709µs
INFO [linters_context/goanalysis] analyzers took 2.813149455s with top 10 stages: fact_purity: 758.80058ms, buildir: 650.577291ms, typedness: 481.034205ms, nilness: 296.102543ms, ctrlflow: 244.157582ms, fact_deprecated: 227.482294ms, printf: 76.501167ms, SA5012: 53.968748ms, inspect: 21.671835ms, SA4014: 440.917µs
INFO [runner] processing took 1.418µs with stages: max_same_issues: 333ns, skip_dirs: 167ns, severity-rules: 125ns, cgo: 125ns, nolint: 125ns, max_from_linter: 84ns, source_code: 42ns, identifier_marker: 42ns, skip_files: 42ns, filename_unadjuster: 42ns, path_prettifier: 42ns, path_shortener: 42ns, autogenerated_exclude: 42ns, diff: 42ns, exclude: 41ns, fixer: 41ns, path_prefixer: 41ns, max_per_file_from_linter: 0s, uniq_by_line: 0s, exclude-rules: 0s, sort_results: 0s
INFO [runner] linters took 1.06527s with stages: goanalysis_metalinter: 1.065250959s
INFO File cache stats: 0 entries of total size 0B
INFO Memory: 14 samples, avg is 177.3MB, max is 252.6MB
INFO Execution took 1.22676475s
Welcome
Description of the problem
We are running golangci-lint using a Golang make/rake -like tool Mage.
There, we have defined a mage target that runs linting as well as other tasks one-by-one in serial order. We encountered that
golangci-lintexits too early and the rest of the tasks following that were not executed.Further examples are provided in the repo URL in the reproductible code section, but in short, when defining mage targets such as:
running
mage checkallskips the latter.Now, when running golangci-lint with debugger it seems, that:
os.exitwas run inpkg/commands/root.go:persistentPostRunfunction.NewExecutor()in here thepersistentPostRunfunction is configured asPersistentPostRunEhandler for CobraSo when linting is run in serial with other commands, golangci-lint exits the task pipeline too early with
os.exiteven when successful, and rest of the tasks are not run. Small (but not sure if relevant) detail is that in this context, golangci-lint is being used as a package library to not require users to install the CLI tool on the host, but using it as an utility library instead. Expected behavior is, that the serial command execution pipeline is exited early only when errors are encountered in the tasks in the pipeline, or finishes all the tasks with successful exit code.Version of golangci-lint
Details
Configuration
Details
Go environment
Details
Verbose output of running
Details
A minimal reproducible example or link to a public repository
Details
Sample repo with reproduction guide: https://github.com/kraashen/golangci-lint-mage-issue-sample
Validation