Fast linters Runner for Go
GNU General Public License v3.0
11569
91
1133

Your feature request related to a problem? Please describe.

As highlighted in https://pkg.go.dev/github.com/golang/mock/gomock#NewController:

New in go1.14+, if you are passing a *testing.T into this function you no longer need to call ctrl.Finish() in your test methods.

Describe the solution you'd like.

A linting rule that can flag when we're unnecessarily calling .Finish, when using a Go version of 1.14+

Describe alternatives you've considered.

N/A

Additional context.

No response

Welcome

  • Yes, I'm using a binary release within 2 latest major releases. Only such installations are supported.
  • Yes, I've searched similar issues on GitHub and didn't find any.
  • Yes, I've included all information below (version, config, etc.).
  • Yes, I've tried with the standalone linter if available (e.g., gocritic, go vet, etc.). (https://golangci-lint.run/usage/linters/)

Description of the problem

"io/ioutil" has been deprecated since Go 1.16: As of Go 1.16, the same functionality is now provided by package io or package os, and those implementations should be preferred in new code. See the specific function documentation for details.

I think ioutil should be replaced with os module.

Version of golangci-lint

none

Configuration file

none

Go environment

none

Verbose output of running

"io/ioutil" has been deprecated since Go 1.16: As of Go 1.16, the same functionality is now provided by package io or package os, and those implementations should be preferred in new code. See the specific function documentation for details.

Code example or link to a public repository

none

I have regularly run golangci-lint run from the root of my directory without issue for the last several weeks. Today, after successfully running golangci-lint run, I fixed all the reported issues and then ran the command in the same terminal but I got the output:

ERRO Running error: context loading failed: no go files to analyze

even though nothing seems to have changed. The project structure is basically 60 or so folders, each having a main.go, a main_test.go and two auto generated files which are ignored by golangci-lint. If I specify a package it lints without issue e.g.:

golangci-lint run ActivityLog

runs the linter on that package without any error.

Version of golangci-lint
$ golangci-lint --version
golangci-lint has version 1.21.0 built from 645e794 on 2019-10-15T18:15:04Z
Config file
$ cat .golangci.yml
run:
  concurrency: 4
  deadline: 2m
  issues-exit-code: 1
  tests: true

output:
  format: colored-line-number
  print-issued-lines: true
  print-linter-name: true

linter-settings:
  errcheck:
    check-type-assertions: true
    check-blank: true

  govet:
    check-shadowing: true
    settings:
      printf:
        funcs:
          - (github.com/golangci/golangci-lint/pkg/logutils.Log).Infof
          - (github.com/golangci/golangci-lint/pkg/logutils.Log).Warnf
          - (github.com/golangci/golangci-lint/pkg/logutils.Log).Errorf
          - (github.com/golangci/golangci-lint/pkg/logutils.Log).Fatalf
  golint:
    min-confidence: 0.8

  gofmt:
    simplify: true

  goimports:
    local-prefixes: kalos-core

  gocyclo:
    min-complexity: 20

  maligned:
    suggest-new: true

  goconst:
    min-len: 3
    min-occurrences: 3

  misspell:
    locale: US
    ignore-words:
      - supercalifragilisticexpialidocious

  lll:
    line-length: 120
    tab-width: 2

  unused:
    check-exported: false

  unparam:
    check-exported: false

  prealloc:
    simple: true
    range-loops: true
    for-loops: false

  gocritic:
    enabled-checks:
      - appendAssign
      - argOrder
      - assignOp
      - badCond
      - boolExprSimplify
      - builtinShadow
      - captLocal
      - caseOrder
      - commendOutCode
      - commentFormatting
      - commentedOutImport
      - defaultCaseOrder
      - deprecatedComment
      - docStub
      - dupArg
      - dupBranchBody
      - dupCase
      - dupSubExpr
      - elseif
      - emptyFallthrough
      - emptyStringTest
      - equalFold
      - exitAfterDefer
      - flagDeref
      - flagName
      - hexLiteral
      - hugeParam
      - ifElseChain
      - importShadow
      - indexAlloc
      - initClause
      - methodExprCall
      - nestingReduce
      - nilValReturn
      - octalLiteral
      - offBy1
      - paramTypeCombine
      - ptrToRefParam
      - rangeExprCopy
      - rangeValCopy
      - regexpMust
      - singleCaseSwitch
      - sloppyLen
      - sloppyReassign
      - stringXbytes
      - switchTrue
      - typeAssertChain
      - typeSwitchVar
      - typeUnparen
      - underef
      - unlabelStmt
      - unlambda
      - unnecessaryBlock
      - unslice
      - valSwap
      - weakCond
      - wrapperFunc
      - yodaStyleExpr

    disabled-checks:
      - codegenComment
      - unnamedResult

linters:
  enable:
    - bodyclose
    - megacheck
    - govet
    - errcheck
    - staticcheck
    - unused
    - gosimple
    - structcheck
    - varcheck
    - ineffassign
    - deadcode
    - typecheck
    - gosec
    - interfacer
    - unconvert
    - goconst
    - gocyclo
    - goimports
    - maligned
    - misspell
    - unparam
    - scopelint
    - gocritic
    - gochecknoinits
  disable:
    - dupl
    - lll
    - stylecheck
Go environment
$ go version && go env
go version go1.13.1 darwin/amd64
GO111MODULE="on"
GOARCH="amd64"
GOBIN="/Users/robertmilejczak/Documents/Projects/bin"
GOCACHE="/Users/robertmilejczak/Library/Caches/go-build"
GOENV="/Users/robertmilejczak/Library/Application Support/go/env"
GOEXE=""
GOFLAGS=""
GOHOSTARCH="amd64"
GOHOSTOS="darwin"
GONOPROXY=""
GONOSUMDB=""
GOOS="darwin"
GOPATH="/Users/robertmilejczak/Documents/Projects"
GOPRIVATE=""
GOPROXY="https://proxy.golang.org,direct"
GOROOT="/usr/local/Cellar/go/1.13.1/libexec"
GOSUMDB="sum.golang.org"
GOTMPDIR=""
GOTOOLDIR="/usr/local/Cellar/go/1.13.1/libexec/pkg/tool/darwin_amd64"
GCCGO="gccgo"
AR="ar"
CC="clang"
CXX="clang++"
CGO_ENABLED="1"
GOMOD="/Users/robertmilejczak/Documents/Projects/src/github.com/rmilejcz/kalos-core/go.mod"
CGO_CFLAGS="-g -O2"
CGO_CPPFLAGS=""
CGO_CXXFLAGS="-g -O2"
CGO_FFLAGS="-g -O2"
CGO_LDFLAGS="-g -O2"
PKG_CONFIG="pkg-config"
GOGCCFLAGS="-fPIC -m64 -pthread -fno-caret-diagnostics -Qunused-arguments -fmessage-length=0 -fdebug-prefix-map=/var/folders/kv/npdslxvd0ml09ntv_0rsmqcr0000gn/T/go-build078154239=/tmp/go-build -gno-record-gcc-switches -fno-common"
Verbose output of running
$ golangci-lint run -v
INFO [config_reader] Config search paths: [./ /Users/robertmilejczak/Documents/Projects/src/github.com/rmilejcz/kalos-core/server /Users/robertmilejczak/Documents/Projects/src/github.com/rmilejcz/kalos-core /Users/robertmilejczak/Documents/Projects/src/github.com/rmilejcz /Users/robertmilejczak/Documents/Projects/src/github.com /Users/robertmilejczak/Documents/Projects/src /Users/robertmilejczak/Documents/Projects /Users/robertmilejczak/Documents /Users/robertmilejczak /Users /] 
INFO [config_reader] Used config file ../.golangci.yml 
INFO [lintersdb] Active 23 linters: [bodyclose deadcode errcheck gochecknoinits goconst gocritic gocyclo goimports gosec gosimple govet ineffassign interfacer maligned misspell scopelint staticcheck structcheck typecheck unconvert unparam unused varcheck] 
INFO [loader] Go packages loading at mode 575 (types_sizes|deps|imports|name|compiled_files|exports_file|files) took 1.436796726s 
ERRO Running error: context loading failed: no go files to analyze 
INFO Memory: 16 samples, avg is 68.9MB, max is 68.9MB 
INFO Execution took 1.451511334s

Welcome

  • Yes, I'm using a binary release within 2 latest major releases. Only such installations are supported.
  • Yes, I've searched similar issues on GitHub and didn't find any.
  • Yes, I've included all information below (version, config, etc).
  • Yes, I've tried with the standalone linter if available. (https://golangci-lint.run/usage/linters/)

Description of the problem

While waiting for full 1.18 support, I attempted to disable the typecheck linter which was giving me grief.

I added it to this section of my config:

linters:
  enable-all: true
  disable:
  - typecheck
  - etc...

But it had no effect.

According to the docs this should be possible.

In the end I did the following:

issues:
  exclude-rules:
  - path: /
    linters:
    - typecheck

Version of golangci-lint

$ golangci-lint --version
golangci-lint has version 1.46.2 built from a3336890 on 2022-05-17T11:31:29Z

Configuration file

$ cat .golangci.yml
run:
    go: "1.18"
    timeout: 10m
    tests: false
    allow-parallel-runners: true
    skip-dirs:
      - "./*/mock"

linters-settings:
  funlen:
    lines: 110
    statements: 60
  staticcheck:
    go: "1.18"
  stylecheck:
    go: "1.18"
  cyclop:
    max-complexity: 15
    skip-tests: true
  gosec:
    exclude-generated: true
  lll:
    line-length: 120
  misspell:
    locale: GB
  goimports:
    local-prefixes: github.com/weaveworks/flintlock
  govet:
    check-shadowing: true
  nolintlint:
    allow-leading-space: false
    allow-unused: false
    require-explanation: true
    require-specific: false
  varnamelen:
    ignore-names:
    - err
    - wg
    - fs
    - id
    - vm
    - ns
    - ip

issues:
  max-same-issues: 0
  max-issues-per-linter: 0
  exclude-rules:
  - text: "should not use dot imports|don't use an underscore in package name"
    linters:
    - golint
  - text: "local replacement are not allowed: github.com/weaveworks/flintlock/"
    linters:
    - gomoddirectives
  - text: "sig: func github.com/weaveworks/flintlock/"
    linters:
    - wrapcheck
  - source: "https://"
    linters:
    - lll
  - path: pkg/defaults/
    linters:
    - lll
  - path: _test\.go
    linters:
    - goerr113
    - gocyclo
    - errcheck
    - gosec
    - dupl
    - funlen
    - scopelint
    - testpackage
  - path: internal/version/
    linters:
    - gochecknoglobals
  - path: internal/command/
    linters:
    - exhaustivestruct
    - lll
    - wrapcheck
  - source: "// .* #\\d+"
    linters:
    - godox
  - path: test/e2e/
    linters:
    - goerr113
    - gomnd

linters:
  enable-all: true
  disable:
  - exhaustivestruct
  - golint
  - interfacer
  - ireturn
  - maligned
  - nilnil
  - scopelint
  - tagliatelle
  - gomoddirectives
  - typecheck

Go environment

$ go version && go env
go version go1.18.3 linux/amd64
GO111MODULE=""
GOARCH="amd64"
GOBIN=""
GOCACHE="/home/claudia/.cache/go-build"
GOENV="/home/claudia/.config/go/env"
GOEXE=""
GOEXPERIMENT=""
GOFLAGS=""
GOHOSTARCH="amd64"
GOHOSTOS="linux"
GOINSECURE=""
GOMODCACHE="/home/claudia/go/pkg/mod"
GONOPROXY=""
GONOSUMDB=""
GOOS="linux"
GOPATH="/home/claudia/go"
GOPRIVATE=""
GOPROXY="https://proxy.golang.org,direct"
GOROOT="/usr/local/go"
GOSUMDB="sum.golang.org"
GOTMPDIR=""
GOTOOLDIR="/usr/local/go/pkg/tool/linux_amd64"
GOVCS=""
GOVERSION="go1.18.3"
GCCGO="gccgo"
GOAMD64="v1"
AR="ar"
CC="gcc"
CXX="g++"
CGO_ENABLED="1"
GOMOD="/home/claudia/workspace/flintlock/go.mod"
GOWORK=""
CGO_CFLAGS="-g -O2"
CGO_CPPFLAGS=""
CGO_CXXFLAGS="-g -O2"
CGO_FFLAGS="-g -O2"
CGO_LDFLAGS="-g -O2"
PKG_CONFIG="pkg-config"
GOGCCFLAGS="-fPIC -m64 -pthread -fmessage-length=0 -fdebug-prefix-map=/tmp/go-build1873054285=/tmp/go-build -gno-record-gcc-switches"

Verbose output of running

$ golangci-lint cache clean
$ golangci-lint run -v
INFO [config_reader] Config search paths: [./ /home/claudia/workspace/flintlock /home/claudia/workspace /home/claudia /home /]
INFO [config_reader] Used config file .golangci.yml
INFO [lintersdb] Active 73 linters: [asciicheck bidichk bodyclose contextcheck cyclop deadcode depguard dogsled dupl durationcheck errcheck errname errorlint exhaustive exportloopref forbidigo forcetypeassert funlen gci gochecknoglobals gochecknoinits gocognit goconst gocritic gocyclo godot godox goerr113 gofmt gofumpt goheader goimports gomnd gomodguard goprintffuncname gosec gosimple govet ifshort importas ineffassign lll makezero misspell nakedret nestif nilerr nlreturn noctx nolintlint paralleltest prealloc predeclared promlinter revive rowserrcheck sqlclosecheck staticcheck structcheck stylecheck tenv testpackage thelper tparallel unconvert unparam unused varcheck varnamelen wastedassign whitespace wrapcheck wsl]
INFO [loader] Go packages loading at mode 575 (deps|exports_file|imports|compiled_files|files|name|types_sizes) took 271.667642ms
INFO [runner/filename_unadjuster] Pre-built 0 adjustments in 5.868339ms
INFO [linters context] importas settings found, but no aliases listed. List aliases under alias: key.
INFO [linters context/goanalysis] analyzers took 2.284062685s with top 10 stages: the_only_name: 72.982384ms, gocritic: 34.429007ms, godox: 28.403245ms, ineffassign: 23.718449ms, directives: 20.996316ms, buildtag: 20.314691ms, testpackage: 20.134428ms, errorlint: 20.052842ms, dupl: 19.97993ms, ST1012: 17.987856ms
INFO [runner] Issues before processing: 11228, after processing: 51
INFO [runner] Processors filtering stat (out/in): max_per_file_from_linter: 51/51, filename_unadjuster: 11228/11228, path_prettifier: 11228/11228, diff: 51/51, sort_results: 51/51, autogenerated_exclude: 11228/11228, identifier_marker: 11228/11228, max_same_issues: 51/51, max_from_linter: 51/51, source_code: 51/51, path_shortener: 51/51, severity-rules: 51/51, skip_files: 11228/11228, skip_dirs: 11228/11228, nolint: 11220/11220, uniq_by_line: 51/11220, path_prefixer: 51/51, cgo: 11228/11228, exclude: 11228/11228, exclude-rules: 11220/11228
INFO [runner] processing took 420.037627ms with stages: exclude-rules: 286.927974ms, identifier_marker: 120.318589ms, nolint: 4.713532ms, path_prettifier: 3.85884ms, skip_dirs: 1.113003ms, cgo: 811.036µs, uniq_by_line: 762.391µs, autogenerated_exclude: 714.042µs, filename_unadjuster: 660.512µs, source_code: 141.818µs, path_shortener: 9.496µs, max_per_file_from_linter: 3.414µs, max_same_issues: 1.146µs, skip_files: 414ns, diff: 344ns, sort_results: 305ns, severity-rules: 253ns, max_from_linter: 234ns, exclude: 205ns, path_prefixer: 79ns
INFO [runner] linters took 4.236279675s with stages: goanalysis_metalinter: 3.816156997s
INFO File cache stats: 14 entries of total size 57.8KiB
INFO Memory: 47 samples, avg is 336.5MB, max is 409.5MB
INFO Execution took 4.518303126s
hack/tools/bin/golangci-lint run -v --fast=false 
core/models/vmid.go:4:2: could not import encoding (-: could not load export data: cannot import "encoding" (unstable iexport format version 2, just rebuild compiler and std library), export data is newer version - update tool) (typecheck)
	"encoding"
	^
internal/command/flags/urfave.go:9:29: undeclared name: `cli` (typecheck)
type WithFlagsFunc func() []cli.Flag
                            ^
internal/command/flags/urfave.go:11:43: undeclared name: `cli` (typecheck)
func CLIFlags(options ...WithFlagsFunc) []cli.Flag {
                                          ^
internal/command/flags/urfave.go:62:37: undeclared name: `cli` (typecheck)
func ParseFlags(cfg *config.Config) cli.BeforeFunc {
                                    ^
internal/command/flags/urfave.go:12:13: undeclared name: `cli` (typecheck)
	flags := []cli.Flag{}
	           ^
internal/command/flags/urfave.go:22:18: undeclared name: `cli` (typecheck)
	return func() []cli.Flag {
	                ^
internal/command/flags/urfave.go:23:12: undeclared name: `cli` (typecheck)
		return []cli.Flag{
		         ^
internal/command/flags/urfave.go:24:5: undeclared name: `cli` (typecheck)
			&cli.StringFlag{
			 ^
internal/command/flags/urfave.go:29:5: undeclared name: `cli` (typecheck)
			&cli.StringFlag{
			 ^
internal/command/flags/urfave.go:39:18: undeclared name: `cli` (typecheck)
	return func() []cli.Flag {
	                ^
internal/command/flags/urfave.go:40:12: undeclared name: `cli` (typecheck)
		return []cli.Flag{
		         ^
internal/command/flags/urfave.go:41:5: undeclared name: `cli` (typecheck)
			&cli.StringFlag{
			 ^
internal/command/flags/urfave.go:51:18: undeclared name: `cli` (typecheck)
	return func() []cli.Flag {
	                ^
internal/command/flags/urfave.go:52:12: undeclared name: `cli` (typecheck)
		return []cli.Flag{
		         ^
internal/command/flags/urfave.go:53:5: undeclared name: `cli` (typecheck)
			&cli.StringFlag{
			 ^
internal/command/flags/urfave.go:63:19: undeclared name: `cli` (typecheck)
	return func(ctx *cli.Context) error {
	                 ^
internal/command/flags/urfave.go:4:2: "github.com/urfave/cli/v2" imported but not used (typecheck)
	"github.com/urfave/cli/v2"
	^
core/application/commands.go:10:2: could not import github.com/weaveworks-liquidmetal/flintlock/client/cloudinit (-: could not load export data: cannot import "github.com/weaveworks-liquidmetal/flintlock/client/cloudinit" (unstable iexport format version 2, just rebuild compiler and std library), export data is newer version - update tool) (typecheck)
	"github.com/weaveworks-liquidmetal/flintlock/client/cloudinit"
	^
core/application/commands.go:11:2: could not import github.com/weaveworks-liquidmetal/flintlock/client/cloudinit/instance (-: could not load export data: cannot import "github.com/weaveworks-liquidmetal/flintlock/client/cloudinit/instance" (unstable iexport format version 2, just rebuild compiler and std library), export data is newer version - update tool) (typecheck)
	"github.com/weaveworks-liquidmetal/flintlock/client/cloudinit/instance"
	^
infrastructure/containerd/client_interface.go:57:16: undeclared name: `tasks` (typecheck)
	TaskService() tasks.TasksClient
	              ^
infrastructure/containerd/repo.go:268:73: undeclared name: `digest` (typecheck)
func (r *containerdRepo) getWithDigest(ctx context.Context, metadigest *digest.Digest) (*models.MicroVM, error) {
                                                                        ^
infrastructure/containerd/repo.go:288:5: undeclared name: `digest` (typecheck)
) (*digest.Digest, error) {
    ^
infrastructure/containerd/repo.go:337:96: undeclared name: `digest` (typecheck)
func (r *containerdRepo) findAllDigestForSpec(ctx context.Context, name, namespace string) ([]*digest.Digest, error) {
                                                                                               ^
infrastructure/containerd/repo.go:146:25: undeclared name: `digest` (typecheck)
	digests := map[string]*digest.Digest{}
	                       ^
infrastructure/containerd/repo.go:289:14: undeclared name: `digest` (typecheck)
	var digest *digest.Digest
	            ^
infrastructure/containerd/repo.go:343:16: undeclared name: `digest` (typecheck)
	digests := []*digest.Digest{}
	              ^
infrastructure/containerd/client_interface.go:7:2: "github.com/containerd/containerd/api/services/tasks/v1" imported but not used (typecheck)
	"github.com/containerd/containerd/api/services/tasks/v1"
	^
infrastructure/containerd/repo.go:15:2: "github.com/opencontainers/go-digest" imported but not used (typecheck)
	"github.com/opencontainers/go-digest"
	^
infrastructure/controllers/microvm_controller.go:11:2: "github.com/weaveworks-liquidmetal/flintlock/api/events" imported but not used (typecheck)
	"github.com/weaveworks-liquidmetal/flintlock/api/events"
	^
infrastructure/firecracker/config.go:8:12: could not import github.com/weaveworks-liquidmetal/flintlock/client/cloudinit/network (-: could not load export data: cannot import "github.com/weaveworks-liquidmetal/flintlock/client/cloudinit/network" (unstable iexport format version 2, just rebuild compiler and std library), export data is newer version - update tool) (typecheck)
	cinetwork "github.com/weaveworks-liquidmetal/flintlock/client/cloudinit/network"
	          ^
infrastructure/firecracker/config.go:211:11: undeclared name: `firecracker` (typecheck)
			DHCP4: firecracker.Bool(true),
			       ^
infrastructure/firecracker/config.go:212:11: undeclared name: `firecracker` (typecheck)
			DHCP6: firecracker.Bool(true),
			       ^
infrastructure/firecracker/config.go:230:13: undeclared name: `yaml` (typecheck)
	nd, err := yaml.Marshal(network)
	           ^
infrastructure/firecracker/config.go:270:14: undeclared name: `firecracker` (typecheck)
	eth.DHCP4 = firecracker.Bool(false)
	            ^
infrastructure/firecracker/config.go:271:14: undeclared name: `firecracker` (typecheck)
	eth.DHCP6 = firecracker.Bool(false)
	            ^
infrastructure/firecracker/create.go:54:9: undeclared name: `firecracker` (typecheck)
	cmd := firecracker.VMCommandBuilder{}.
	       ^
infrastructure/firecracker/config.go:7:2: "github.com/firecracker-microvm/firecracker-go-sdk" imported but not used (typecheck)
	"github.com/firecracker-microvm/firecracker-go-sdk"
	^
infrastructure/firecracker/config.go:12:2: "gopkg.in/yaml.v3" imported but not used (typecheck)
	"gopkg.in/yaml.v3"
	^
infrastructure/firecracker/create.go:10:2: "github.com/firecracker-microvm/firecracker-go-sdk" imported but not used (typecheck)
	"github.com/firecracker-microvm/firecracker-go-sdk"
	^
infrastructure/grpc/convert.go:7:2: could not import github.com/weaveworks-liquidmetal/flintlock/client/cloudinit/instance (-: could not load export data: cannot import "github.com/weaveworks-liquidmetal/flintlock/client/cloudinit/instance" (unstable iexport format version 2, just rebuild compiler and std library), export data is newer version - update tool) (typecheck)
	"github.com/weaveworks-liquidmetal/flintlock/client/cloudinit/instance"
	^
infrastructure/grpc/server.go:56:16: undeclared name: `validator` (typecheck)
	var valErrors validator.ValidationErrors
	              ^
infrastructure/grpc/server.go:8:2: "github.com/go-playground/validator/v10" imported but not used (typecheck)
	"github.com/go-playground/validator/v10"
	^
internal/command/metrics/main.go:9:29: undeclared name: `cli` (typecheck)
func NewApp(out io.Writer) *cli.App {
                            ^
internal/command/metrics/main.go:23:20: undeclared name: `cli` (typecheck)
func commands() []*cli.Command {
                   ^
internal/command/metrics/serve.go:20:22: undeclared name: `cli` (typecheck)
func serveCommand() *cli.Command {
                     ^
internal/command/metrics/main.go:10:9: undeclared name: `cli` (typecheck)
	app := cli.NewApp()
	       ^
internal/command/metrics/main.go:24:12: undeclared name: `cli` (typecheck)
	return []*cli.Command{
	          ^
internal/command/metrics/serve.go:23:10: undeclared name: `cli` (typecheck)
	return &cli.Command{
	        ^
internal/command/metrics/serve.go:33:19: undeclared name: `cli` (typecheck)
		Action: func(c *cli.Context) error {
		                ^
internal/command/metrics/main.go:6:2: "github.com/urfave/cli/v2" imported but not used (typecheck)
	"github.com/urfave/cli/v2"
	^
internal/command/metrics/serve.go:10:2: "github.com/urfave/cli/v2" imported but not used (typecheck)
	"github.com/urfave/cli/v2"
	^

Code example or link to a public repository

https://github.com/weaveworks-liquidmetal/flintlock

After godox linter was added I'm having an error which is not yet fixable in my code:

main.go:58  godox  main.go:58: Line contains TODO/BUG/FIXME: "TODO(kahlers): Replace with proper limit..."

Seeing this TODO comment in the lint is great because it reminds me I need to do something about that. Sadly the issue was prioritized as "lets do this later" as it is not a business critical issue.

Therefore having an option to set (for example) godox as a warn only linter which reminds me I need to do something but does not fail the linter (if there are only warn only errors left, exit with status 0 instead of 1) would be great.

Sure I also could just add a //nolint:godox but that would also make the output vanish…

Welcome

  • Yes, I'm using a binary release within 2 latest major releases. Only such installations are supported.
  • Yes, I've searched similar issues on GitHub and didn't find any.
  • Yes, I've included all information below (version, config, etc.).
  • Yes, I've tried with the standalone linter if available (e.g., gocritic, go vet, etc.). (https://golangci-lint.run/usage/linters/)

Description of the problem

Running the linter returns the following error:

WARN [runner] Can't run linter goanalysis_metalinter: buildir: failed to load package proj: could not load export data: no export data for "github.com/pebbe/go-proj-4/proj"
ERRO Running error: 1 error occurred:
	* can't run linter goanalysis_metalinter: buildir: failed to load package proj: could not load export data: no export data for "github.com/pebbe/go-proj-4/proj"

After a bit of debugging, I found returning nil appears to prevent the error, but may just be a hack that hides a deeper problem, which I think is around understanding why github.com/pebbe/go-proj-4/proj doesn't have an exportFile.

I'd be appreciative if someone could explain how exportFiles are generated and why it's missing for github.com/pebbe/go-proj-4/proj; or, if this is "expected", whether if my proposed change is an appropriate fix: https://github.com/golangci/golangci-lint/compare/master...albertteoh:golangci-lint:warn-instead-of-err-no-exportfile?expand=1.

Worth noting that I do not see this error when running with the docker image: golangci/golangci-lint:v1.43-alpine
... and this error starts appearing from golangci/golangci-lint:v1.44-alpine.

Version of golangci-lint

$ golangci-lint --version
golangci-lint has version 1.50.1 built from 8926a95f on 2022-10-22T10:50:47Z

Configuration file

$ cat .golangci.yml
run:
  timeout: 5m
  modules-download-mode: vendor
  go: "1.19"

issues:
  exclude-rules:
    - path: '(.+)_test\.go'
      linters:
        - gosec

linter-settings:
  depguard:
    list-type: blacklist
    include-go-root: true
    packages:
      - io/ioutil
    packages-with-error-message:
      - io/ioutil: "Use os or io instead of io/ioutil"
  goimports:
    local-prefixes: github.com/nearmap/openworld
  gosimple:
    go: "1.19"
    checks: ["all"]

linters:
  fast: false
  enable:
    - depguard
    - gofmt
    - gofumpt
    - goimports
    - gosec
    - govet
    - misspell

Go environment

$ go version && go env
go version go1.19.1 linux/amd64
GO111MODULE=""
GOARCH="amd64"
GOBIN=""
GOCACHE="/home/vagrant/.cache/go-build"
GOENV="/home/vagrant/.config/go/env"
GOEXE=""
GOEXPERIMENT=""
GOFLAGS=""
GOHOSTARCH="amd64"
GOHOSTOS="linux"
GOINSECURE=""
GOMODCACHE="/vagrant/go/pkg/mod"
GONOPROXY=""
GONOSUMDB=""
GOOS="linux"
GOPATH="/vagrant/go"
GOPRIVATE=""
GOPROXY="https://proxy.golang.org,direct"
GOROOT="/usr/local/go"
GOSUMDB="sum.golang.org"
GOTMPDIR=""
GOTOOLDIR="/usr/local/go/pkg/tool/linux_amd64"
GOVCS=""
GOVERSION="go1.19.1"
GCCGO="gccgo"
GOAMD64="v1"
AR="ar"
CC="gcc"
CXX="g++"
CGO_ENABLED="1"
GOMOD="/vagrant/go/src/github.com/nearmap/openworld/go.mod"
GOWORK=""
CGO_CFLAGS="-g -O2"
CGO_CPPFLAGS=""
CGO_CXXFLAGS="-g -O2"
CGO_FFLAGS="-g -O2"
CGO_LDFLAGS="-g -O2"
PKG_CONFIG="pkg-config"
GOGCCFLAGS="-fPIC -m64 -pthread -Wl,--no-gc-sections -fmessage-length=0 -fdebug-prefix-map=/tmp/go-build2885735728=/tmp/go-build -gno-record-gcc-switches"```

Verbose output of running

$ golangci-lint cache clean
$ golangci-lint run -v
INFO [config_reader] Config search paths: [./ /vagrant/go/src/github.com/nearmap/openworld /vagrant/go/src/github.com/nearmap /vagrant/go/src/github.com /vagrant/go/src /vagrant/go /vagrant / /home/vagrant]
INFO [config_reader] Used config file .golangci.yaml
INFO [lintersdb] Active 13 linters: [depguard errcheck gofmt gofumpt goimports gosec gosimple govet ineffassign misspell staticcheck typecheck unused]
INFO [loader] Go packages loading at mode 575 (compiled_files|exports_file|files|imports|deps|name|types_sizes) took 17.15944041s
INFO [runner/filename_unadjuster] Pre-built 0 adjustments in 134.341821ms
INFO [linters_context/goanalysis] analyzers took 1m15.456566948s with top 10 stages: buildir: 44.298340449s, gofumpt: 4.425482723s, goimports: 4.386180343s, gofmt: 4.236456711s, misspell: 4.019975918s, isgenerated: 3.115835806s, inspect: 1.612242537s, gosec: 1.222692737s, ctrlflow: 915.632099ms, printf: 880.704774ms
WARN [runner] Can't run linter goanalysis_metalinter: buildir: failed to load package proj: could not load export data: no export data for "github.com/pebbe/go-proj-4/proj"
INFO [runner] processing took 2.378µs with stages: max_same_issues: 450ns, max_from_linter: 298ns, nolint: 273ns, skip_dirs: 242ns, cgo: 112ns, filename_unadjuster: 102ns, skip_files: 101ns, uniq_by_line: 99ns, path_prettifier: 99ns, autogenerated_exclude: 97ns, severity-rules: 95ns, exclude: 92ns, max_per_file_from_linter: 44ns, diff: 44ns, sort_results: 43ns, exclude-rules: 40ns, identifier_marker: 38ns, path_shortener: 38ns, source_code: 37ns, path_prefixer: 34ns
INFO [runner] linters took 19.846467904s with stages: goanalysis_metalinter: 19.846438948s
ERRO Running error: 1 error occurred:
	* can't run linter goanalysis_metalinter: buildir: failed to load package proj: could not load export data: no export data for "github.com/pebbe/go-proj-4/proj"

INFO Memory: 370 samples, avg is 361.5MB, max is 1005.1MB
INFO Execution took 37.153737047s```

Code example or link to a public repository

This affects a private repository. However, the dependency that seems to be the cause of this error is: github.com/pebbe/go-proj-4/proj

// add your code here

Welcome

  • Yes, I'm using a binary release within 2 latest major releases. Only such installations are supported.
  • Yes, I've searched similar issues on GitHub and didn't find any.
  • Yes, I've included all information below (version, config, etc.).
  • Yes, I've tried with the standalone linter if available (e.g., gocritic, go vet, etc.). (https://golangci-lint.run/usage/linters/)

Description of the problem

while linting our codebase on a PR:
cloudfoundry/app-autoscaler-release#1086
The error seems to be on an unrelated code bit that has not changed.
From the erorr it seems like the timezone is not accounted for but we have been successfully linting this for a while.

ERRO Running error: 1 error occurred:
        * can't run linter goanalysis_metalinter: goimports: can't extract issues from gofmt diff output "--- /app-autoscaler-release/src/autoscaler/fakes/fake_metric_forwarder.go.orig\t2022-11-24 15:16:15\n+++ /app-autoscaler-release/src/autoscaler/fakes/fake_metric_forwarder.go\t2022-11-24 15:16:15\n@@ -2,9 +2,10 @@\n package fakes\n \n import (\n+\t\"sync\"\n+\n \t\"code.cloudfoundry.org/app-autoscaler/src/autoscaler/metricsforwarder/forwarder\"\n \t\"code.cloudfoundry.org/app-autoscaler/src/autoscaler/models\"\n-\t\"sync\"\n )\n \n type FakeMetricForwarder struct {\n": can't parse patch: parsing time "2022-11-24 15:16:15" as "2006-01-02 15:04:05 -0700": cannot parse "" as "-0700"

Version of golangci-lint

$ golangci-lint --version
golangci-lint has version 1.50.1 built from 8926a95f on 2022-10-22T10:50:47Z

Configuration file

$ cat .golangci.yml
# golangci.com configuration
# https://github.com/golangci/golangci/wiki/Configuration
---
linters-settings:
  depguard:
    list-type: blacklist
    packages:
      - github.com/alecthomas/assert
      - github.com/magiconair/properties/assert
    packages-with-error-message:
      - github.com/alecthomas/assert: "use github.com/stretchr/testify/assert"
      - github.com/magiconair/properties/assert: "use github.com/stretchr/testify/assert"
  dupl:
    threshold: 100
  exhaustive:
    default-signifies-exhaustive: false
  funlen:
    lines: 250
    statements: 150
  goconst:
    min-len: 3
    min-occurrences: 3
  gocognit:
    min-complexity: 15
  gocritic:
    enabled-tags:
      - diagnostic
      - experimental
      - opinionated
      - performance
      - style
    disabled-checks:
      - dupImport # https://github.com/go-critic/go-critic/issues/845
      - ifElseChain
      - octalLiteral
      - whyNoLint
      - wrapperFunc
  gocyclo:
    min-complexity: 30
  gomnd:
    settings:
      mnd:
        # don't include the "operation" and "assign"
        checks:
          - argument
          - case
          - condition
          - return
  govet:
    check-shadowing: true
  lll:
    line-length: 140
  maligned:
    suggest-new: true
  nolintlint:
    allow-leading-space: true # don't require machine-readable nolint directives (i.e. with no leading space)
    allow-unused: false # report any unused nolint directives
    require-explanation: false # don't require an explanation for nolint directives
    require-specific: false # don't require nolint directives to be specific about which linter is being skipped
  staticcheck:
    checks: ["all"]
  stylecheck:
    go: "1.15"
    # https://staticcheck.io/docs/options#checks
    checks: ["all", "-ST1003", "-ST1005"]
    dot-import-whitelist:
      - github.com/onsi/ginkgo/v2
      - github.com/onsi/gomega
      - github.com/onsi/gomega/gexec
    # https://staticcheck.io/docs/options#initialisms
    #initialisms: ["ACL", "API", "ASCII", "CPU", "CSS", "DNS", "EOF", "GUID", "HTML", "HTTP", "HTTPS", "ID", "IP", "JSON", "QPS", "RAM", "RPC", "SLA", "SMTP", "SQL", "SSH", "TCP", "TLS", "TTL", "UDP", "UI", "GID", "UID", "UUID", "URI", "URL", "UTF8", "VM", "XML", "XMPP", "XSRF", "XSS"]
    # https://staticcheck.io/docs/options#http_status_code_whitelist
    #http-status-code-whitelist: ["200", "400", "404", "500"]
linters:
  # please, do not use `enable-all`: it's deprecated and will be removed soon.
  # inverted configuration with `enable-all` and `disable` is not scalable during updates of golangci-lint
  disable-all: true
  enable:
    - asciicheck
    - bodyclose
    - depguard
    - dogsled
      #- dupl
    - errcheck
    - funlen
      #    - gocognit
      #    - goconst
      #    - gocyclo
    - gofmt
    - goimports
    - goprintffuncname
    - gosec
    - gosimple
      # - gomoddirectives - commented out to allow replace directives
    - gomodguard
    - ineffassign
    - misspell
    - nakedret
    - nolintlint
    - rowserrcheck
    - staticcheck
    - stylecheck
    - testpackage
    - typecheck
      #    - unconvert
      #    - unparam
    - unused
    - whitespace
      #    - godox
      #    - staticcheck
      #    - prealloc
issues:
  # Excluding configuration per-path, per-linter, per-text and per-source
  exclude-rules:
    - path: _test\.go
      linters:
        - dupl
        - gomnd
        - typecheck
  max-same-issues: 0
run:
  go: '1.19'

Go environment

$ go version && go env
go version go1.19.3 darwin/amd64
GO111MODULE="on"
GOARCH="amd64"
GOBIN=""
GOCACHE="/Users/kevincross/Library/Caches/go-build"
GOENV="/Users/kevincross/Library/Application Support/go/env"
GOEXE=""
GOEXPERIMENT=""
GOFLAGS=""
GOHOSTARCH="amd64"
GOHOSTOS="darwin"
GOINSECURE=""
GOMODCACHE="/Users/kevincross/SAPDevelop/go/pkg/mod"
GONOPROXY="github.tools.sap"
GONOSUMDB="github.tools.sap"
GOOS="darwin"
GOPATH="/Users/kevincross/SAPDevelop/go"
GOPRIVATE="github.tools.sap"
GOPROXY="https://proxy.golang.org,direct"
GOROOT="/Users/kevincross/SAPDevelop/.asdf/installs/golang/1.19.3/go"
GOSUMDB="sum.golang.org"
GOTMPDIR=""
GOTOOLDIR="/Users/kevincross/SAPDevelop/.asdf/installs/golang/1.19.3/go/pkg/tool/darwin_amd64"
GOVCS=""
GOVERSION="go1.19.3"
GCCGO="gccgo"
GOAMD64="v1"
AR="ar"
CC="clang"
CXX="clang++"
CGO_ENABLED="1"
GOMOD="/dev/null"
GOWORK=""
CGO_CFLAGS="-g -O2"
CGO_CPPFLAGS=""
CGO_CXXFLAGS="-g -O2"
CGO_FFLAGS="-g -O2"
CGO_LDFLAGS="-g -O2"
PKG_CONFIG="pkg-config"
GOGCCFLAGS="-fPIC -arch x86_64 -m64 -pthread -fno-caret-diagnostics -Qunused-arguments -fmessage-length=0 -fdebug-prefix-map=/var/folders/xk/fqv769xd4r1b2zhv07dttg_m0000gn/T/go-build2333628043=/tmp/go-build -gno-record-gcc-switches -fno-common"

Verbose output of running

$ golangci-lint cache clean
$ golangci-lint run -v

INFO [config_reader] Used config file ../../.golangci.yaml 
INFO [lintersdb] Active 23 linters: [asciicheck bodyclose depguard dogsled errcheck funlen gofmt goimports gomodguard goprintffuncname gosec gosimple ineffassign misspell nakedret nolintlint rowserrcheck staticcheck stylecheck testpackage typecheck unused whitespace] 
INFO [loader] Go packages loading at mode 575 (name|types_sizes|deps|imports|files|compiled_files|exports_file) took 4.461632641s 
INFO [runner/filename_unadjuster] Pre-built 0 adjustments in 62.542452ms 
INFO [linters_context/goanalysis] analyzers took 2m24.278301791s with top 10 stages: buildir: 19.454396676s, goimports: 11.015089144s, buildssa: 10.755394003s, fact_deprecated: 3.883148827s, S1038: 3.859892261s, nilness: 3.800664085s, gosec: 3.502604981s, typedness: 3.470936742s, fact_purity: 3.436012862s, gofmt: 3.401190906s 
WARN [runner] Can't run linter goanalysis_metalinter: goimports: can't extract issues from gofmt diff output "--- /Users/kevincross/SAPDevelop/cf/app-autoscaler-release/src/autoscaler/fakes/fake_metric_forwarder.go.orig\t2022-11-24 15:50:09\n+++ /Users/kevincross/SAPDevelop/cf/app-autoscaler-release/src/autoscaler/fakes/fake_metric_forwarder.go\t2022-11-24 15:50:09\n@@ -2,9 +2,10 @@\n package fakes\n \n import (\n+\t\"sync\"\n+\n \t\"code.cloudfoundry.org/app-autoscaler/src/autoscaler/metricsforwarder/forwarder\"\n \t\"code.cloudfoundry.org/app-autoscaler/src/autoscaler/models\"\n-\t\"sync\"\n )\n \n type FakeMetricForwarder struct {\n": can't parse patch: parsing time "2022-11-24 15:50:09" as "2006-01-02 15:04:05 -0700": cannot parse "" as "-0700" 
WARN [linters_context] rowserrcheck is disabled because of generics. You can track the evolution of the generics support by following the https://github.com/golangci/golangci-lint/issues/2649. 
INFO [runner] processing took 8.345µs with stages: max_same_issues: 2.344µs, nolint: 2.122µs, max_from_linter: 1.955µs, skip_dirs: 326ns, max_per_file_from_linter: 170ns, cgo: 134ns, uniq_by_line: 132ns, filename_unadjuster: 131ns, path_prettifier: 129ns, skip_files: 129ns, exclude: 128ns, autogenerated_exclude: 124ns, path_shortener: 85ns, source_code: 64ns, identifier_marker: 63ns, sort_results: 63ns, diff: 62ns, exclude-rules: 62ns, severity-rules: 62ns, path_prefixer: 60ns 
INFO [runner] linters took 10.155204878s with stages: goanalysis_metalinter: 10.154955143s, rowserrcheck: 9.583µs 
ERRO Running error: 1 error occurred:
        * can't run linter goanalysis_metalinter: goimports: can't extract issues from gofmt diff output "--- /Users/kevincross/SAPDevelop/cf/app-autoscaler-release/src/autoscaler/fakes/fake_metric_forwarder.go.orig\t2022-11-24 15:50:09\n+++ /Users/kevincross/SAPDevelop/cf/app-autoscaler-release/src/autoscaler/fakes/fake_metric_forwarder.go\t2022-11-24 15:50:09\n@@ -2,9 +2,10 @@\n package fakes\n \n import (\n+\t\"sync\"\n+\n \t\"code.cloudfoundry.org/app-autoscaler/src/autoscaler/metricsforwarder/forwarder\"\n \t\"code.cloudfoundry.org/app-autoscaler/src/autoscaler/models\"\n-\t\"sync\"\n )\n \n type FakeMetricForwarder struct {\n": can't parse patch: parsing time "2022-11-24 15:50:09" as "2006-01-02 15:04:05 -0700": cannot parse "" as "-0700"
 
INFO Memory: 149 samples, avg is 409.9MB, max is 885.5MB 
INFO Execution took 14.706869763s                 
make: *** [Makefile:255: lint_autoscaler] Error 3

Code example or link to a public repository

PR https://github.com/cloudfoundry/app-autoscaler-release/pull/1086 ```go // add your code here ```

Welcome

  • Yes, I'm using a binary release within 2 latest major releases. Only such installations are supported.
  • Yes, I've searched similar issues on GitHub and didn't find any.
  • Yes, I've included all information below (version, config, etc).
  • Yes, I've tried with the standalone linter if available. (https://golangci-lint.run/usage/linters/)

Description of the problem

When running golangci-lint run -E gofmt I am shown an error:

WARN [linters context] structcheck is disabled because of go1.18. You can track the evolution of the go1.18 support by following the https://github.com/golangci/golangci-lint/issues/2649. 
ERRO Running error: 1 error occurred:
        * can't run linter goanalysis_metalinter: goimports: can't extract issues from gofmt diff output "--- /Users/jacek.leszczynski/RiderProjects/reporting-tools/go/rot/client/reporting.go.orig\t2022-08-10 12:30:31\n+++ /Users/jacek.leszczynski/RiderProjects/reporting-tools/go/rot/client/reporting.go\t2022-08-10 12:30:31\n@@ -4,8 +4,9 @@\n \t\"context\"\n \t\"encoding/json\"\n \t\"fmt\"\n-\t\"github.com/Fonoa-Tech/reporting-api/generated/contracts\"\n \t\"net/url\"\n+\n+\t\"github.com/Fonoa-Tech/reporting-api/generated/contracts\"\n )\n \n type ReportingClient struct {\n": can't parse patch: parsing time "2022-08-10 12:30:31" as "2006-01-02 15:04:05 -0700": cannot parse "" as "-0700"

Version of golangci-lint

golangci-lint has version 1.46.2 built from a333689 on 2022-05-17T06:05:08Z

Configuration file

---
run:
  timeout: 3m
  build-tags:
    - integration

linters:
  enable:
    - misspell
    - goimports
    - revive
    - gofmt
    - depguard
    - godot

Go environment

go version go1.18.2 darwin/arm64
GO111MODULE="on"
GOARCH="arm64"
GOBIN=""
GOCACHE="/Users/jacek.leszczynski/Library/Caches/go-build"
GOENV="/Users/jacek.leszczynski/Library/Application Support/go/env"
GOEXE=""
GOEXPERIMENT=""
GOFLAGS=""
GOHOSTARCH="arm64"
GOHOSTOS="darwin"
GOINSECURE=""
GOMODCACHE="/Users/jacek.leszczynski/gopath/pkg/mod"
GONOPROXY=""
GONOSUMDB=""
GOOS="darwin"
GOPATH="/Users/jacek.leszczynski/gopath"
GOPRIVATE=""
GOPROXY="https://proxy.golang.org,direct"
GOROOT="/opt/homebrew/Cellar/go/1.18.2/libexec"
GOSUMDB="sum.golang.org"
GOTMPDIR=""
GOTOOLDIR="/opt/homebrew/Cellar/go/1.18.2/libexec/pkg/tool/darwin_arm64"
GOVCS=""
GOVERSION="go1.18.2"
GCCGO="gccgo"
AR="ar"
CC="clang"
CXX="clang++"
CGO_ENABLED="1"
GOMOD="/Users/jacek.leszczynski/RiderProjects/reporting-tools/go/rot/go.mod"
GOWORK=""
CGO_CFLAGS="-g -O2"
CGO_CPPFLAGS=""
CGO_CXXFLAGS="-g -O2"
CGO_FFLAGS="-g -O2"
CGO_LDFLAGS="-g -O2"
PKG_CONFIG="pkg-config"
GOGCCFLAGS="-fPIC -arch arm64 -pthread -fno-caret-diagnostics -Qunused-arguments -fmessage-length=0 -fdebug-prefix-map=/var/folders/jc/2hzf075172155k8m2zswff540000gq/T/go-build2249922677=/tmp/go-build -gno-record-gcc-switches -fno-common"

Verbose output of running

INFO [config_reader] Config search paths: [./ /Users/jacek.leszczynski/RiderProjects/reporting-tools/go/rot /Users/jacek.leszczynski/RiderProjects/reporting-tools/go /Users/jacek.leszczynski/RiderProjects/reporting-tools /Users/jacek.leszczynski/RiderProjects /Users/jacek.leszczynski /Users /] 
INFO [config_reader] Used config file .golangci.yml 
INFO [lintersdb] Active 16 linters: [deadcode depguard errcheck godot gofmt goimports gosimple govet ineffassign misspell revive staticcheck structcheck typecheck unused varcheck] 
INFO [loader] Using build tags: [integration]     
INFO [loader] Go packages loading at mode 575 (imports|deps|exports_file|files|name|types_sizes|compiled_files) took 379.585375ms 
INFO [runner/filename_unadjuster] Pre-built 0 adjustments in 3.7755ms 
INFO [linters context/goanalysis] analyzers took 14.276696194s with top 10 stages: buildir: 9.462551828s, inspect: 803.317455ms, fact_deprecated: 507.355007ms, ctrlflow: 430.351534ms, nilness: 429.363872ms, printf: 362.387388ms, fact_purity: 344.798673ms, SA5012: 280.363134ms, the_only_name: 212.144167ms, typedness: 206.551703ms 
WARN [runner] Can't run linter goanalysis_metalinter: goimports: can't extract issues from gofmt diff output "--- /Users/jacek.leszczynski/RiderProjects/reporting-tools/go/rot/client/reporting.go.orig\t2022-08-10 12:33:15\n+++ /Users/jacek.leszczynski/RiderProjects/reporting-tools/go/rot/client/reporting.go\t2022-08-10 12:33:15\n@@ -4,8 +4,9 @@\n \t\"context\"\n \t\"encoding/json\"\n \t\"fmt\"\n-\t\"github.com/Fonoa-Tech/reporting-api/generated/contracts\"\n \t\"net/url\"\n+\n+\t\"github.com/Fonoa-Tech/reporting-api/generated/contracts\"\n )\n \n type ReportingClient struct {\n": can't parse patch: parsing time "2022-08-10 12:33:15" as "2006-01-02 15:04:05 -0700": cannot parse "" as "-0700" 
WARN [linters context] structcheck is disabled because of go1.18. You can track the evolution of the go1.18 support by following the https://github.com/golangci/golangci-lint/issues/2649. 
INFO [runner] processing took 2.708µs with stages: max_same_issues: 958ns, nolint: 334ns, max_from_linter: 333ns, skip_dirs: 208ns, severity-rules: 84ns, max_per_file_from_linter: 84ns, filename_unadjuster: 84ns, cgo: 83ns, autogenerated_exclude: 83ns, skip_files: 42ns, path_prefixer: 42ns, path_prettifier: 42ns, path_shortener: 42ns, sort_results: 42ns, diff: 42ns, exclude: 41ns, exclude-rules: 41ns, identifier_marker: 41ns, source_code: 41ns, uniq_by_line: 41ns 
INFO [runner] linters took 4.578902583s with stages: goanalysis_metalinter: 4.57884975s, structcheck: 10.291µs 
ERRO Running error: 1 error occurred:
        * can't run linter goanalysis_metalinter: goimports: can't extract issues from gofmt diff output "--- /Users/jacek.leszczynski/RiderProjects/reporting-tools/go/rot/client/reporting.go.orig\t2022-08-10 12:33:15\n+++ /Users/jacek.leszczynski/RiderProjects/reporting-tools/go/rot/client/reporting.go\t2022-08-10 12:33:15\n@@ -4,8 +4,9 @@\n \t\"context\"\n \t\"encoding/json\"\n \t\"fmt\"\n-\t\"github.com/Fonoa-Tech/reporting-api/generated/contracts\"\n \t\"net/url\"\n+\n+\t\"github.com/Fonoa-Tech/reporting-api/generated/contracts\"\n )\n \n type ReportingClient struct {\n": can't parse patch: parsing time "2022-08-10 12:33:15" as "2006-01-02 15:04:05 -0700": cannot parse "" as "-0700"
 
INFO Memory: 51 samples, avg is 823.6MB, max is 1302.8MB 
INFO Execution took 4.980535375s 

Code example or link to a public repository

Can't share code

Your feature request related to a problem? Please describe.

Right now there is no way to simply count the number of issues indicated when a particular linter is enabled. It will be useful to add a command line flag that can indicate the count of issues per linter type

Describe the solution you'd like.

Add a command line flag to summarize the count of each linter config enabled or a specific linter alone

Describe alternatives you've considered.

I could use CLI search tools to get it done. E.g. use a tool like ripgrep to pipe the output

golangci-lint run | rg -w errcheck -c
10

Additional context.

No response

Your feature request related to a problem? Please describe.

It would be nice if golangci-lint cli could show a summary of how many issues it found and if possible, also show how many of them are fixable via --fix.

Describe the solution you'd like.

A summary at the end of the CLI run, similar to eslint:

✖ 39 problems (26 errors, 13 warnings)
  0 errors and 1 warning potentially fixable with the `--fix` option.

Additional context.

Maybe the summary should not be printed unless the issue limit is unrestricted as the number might be confusing otherwise. Thought I do think showing all issues should be the default configuration.

issues:
  max-issues-per-linter: 0
  max-same-issues: 0

Your feature request related to a problem? Please describe.

Hi, I've used golangci-lint but after upgrading its version to latest one, I found the linter with AGPL lisence was added(github.com/leonklingele/grouper, PR: #2497).
I can't find discussion around it, but I don't think it's a good idea to use that because user might have to disclose their source codes.

Describe the solution you'd like.

Changing its license or not to use it

Describe alternatives you've considered.

If there is a special reason, we might not have to change it.

Additional context.

No response

Thank you for creating the issue!

  • Yes, I'm using a binary release within 2 latest major releases. Only such installations are supported.
  • Yes, I've searched similar issues on GitHub and didn't find any.
  • Yes, I've included all information below (version, config, etc).

Please include the following information:

Version of golangci-lint
$ golangci-lint --version
golangci-lint has version 1.20.1 built from 849044b on 2019-10-15T19:11:27Z
Config file
$ cat .golangci.yml
---
run:
  concurrency: 6
  deadline: 15m
  issues-exit-code: 1
  tests: true
  skip-dirs:
    - build
    - conf
    - controlplane/scripts
    - forwarder/vppagent/build
    - forwarder/vppagent/conf
    - forwarder/scripts
    - deployments
    - docks
    - scripts
linters-settings:
  errcheck:
    check-type-assertions: false
    check-blank: false
  govet:
    check-shadowing: true
    settings:
      printf:
        funcs:
          - (github.com/golangci/golangci-lint/pkg/logutils.Log).Infof
          - (github.com/golangci/golangci-lint/pkg/logutils.Log).Warnf
          - (github.com/golangci/golangci-lint/pkg/logutils.Log).Errorf
          - (github.com/golangci/golangci-lint/pkg/logutils.Log).Fatalf
  golint:
    min-confidence: 0.8
  goimports:
    local-prefixes: github.com/networkservicemesh/networkservicemesh
  gocyclo:
    min-complexity: 20
  maligned:
    suggest-new: true
  dupl:
    threshold: 100
  goconst:
    min-len: 3
    min-occurrences: 3
  depguard:
    list-type: blacklist
    include-go-root: false
    packages:
      - github.com/davecgh/go-spew/spew
  misspell:
    locale: US
  unused:
    check-exported: true
  unparam:
    check-exported: true
  nakedret:
    max-func-lines: 30
  prealloc:
    simple: true
    range-loops: true
    for-loops: false
  gocritic:
    enabled-checks:
      - rangeValCopy
      - boolExprSimplify
      - badCond
      - methodExprCall
      - paramTypeCombine
      - ptrToRefParam
      - rangeExprCopy
      - captLocal
      - caseOrder
      - defaultCaseOrder
      - dupBranchBody
      - dupSubExpr
      - elseif
      - emptyFallthrough
      - emptyStringTest
      - equalFold
      - indexAlloc
      - nestingReduce
      - nilValReturn
      - yodaStyleExpr
    settings:
      captLocal:
        paramsOnly: true
      rangeValCopy:
        sizeThreshold: 100
linters:
  disable:
    - depguard
    - wsl
    - lll
    - gofmt
    - varcheck  # deprecated
    - unused  # deprecated
    - goimports
  enable-all: true
issues:
  exclude-use-default: false
  max-issues-per-linter: 0
  max-same-issues: 0
  exclude-rules:  # Use relative path from module
    - path: _test\.go
      linters:
        - golint
    - path: integration/const.go
      linters:
        - deadcode
    - path: cmd/admission-webhook/init.go
      linters:
        - gochecknoglobals
        - gochecknoinits
    - path: cmd/nsm-coredns
      linters:
        - gochecknoglobals
        - gochecknoinits
    - path: tools/socket.go
      linters:
        - gochecknoglobals
        - gochecknoinits
        - gosec
    - path: pkg/monitor/
      linters:
        - dupl
    - path: pkg/nsm.nsm.go
      linters:
        - gocyclo  # TODO: reduce nsm.request() complexity
    - path: cloudtest/pkg/utils/process.go
      linters:
        - gosec
    - path: cloudtest/pkg/commands/main.go
      linters:
        - gosec
        - funlen
    - path: probes/health/serve_mux_health.go
      linters:
        - gosec
    - path: kubetest/log_utils.go
      linters:
        - gosec
  exclude:
    - should not use dot imports
    - \`version\` is a global variable
    - not declared by package utf8
    - lines are duplicate of```

</details>

<details><summary>Go environment</summary>

```bash
$ go version && go env
go version go1.13.1 darwin/amd64
GO111MODULE=""
GOARCH="amd64"
GOBIN=""
GOCACHE="/Users/fkautz/Library/Caches/go-build"
GOENV="/Users/fkautz/Library/Application Support/go/env"
GOEXE=""
GOFLAGS=""
GOHOSTARCH="amd64"
GOHOSTOS="darwin"
GONOPROXY=""
GONOSUMDB=""
GOOS="darwin"
GOPATH="/Users/fkautz/go"
GOPRIVATE=""
GOPROXY="https://proxy.golang.org,direct"
GOROOT="/usr/local/Cellar/go/1.13.1/libexec"
GOSUMDB="sum.golang.org"
GOTMPDIR=""
GOTOOLDIR="/usr/local/Cellar/go/1.13.1/libexec/pkg/tool/darwin_amd64"
GCCGO="gccgo"
AR="ar"
CC="clang"
CXX="clang++"
CGO_ENABLED="1"
GOMOD="/Users/fkautz/src/networkservicemesh/go.mod"
CGO_CFLAGS="-g -O2"
CGO_CPPFLAGS=""
CGO_CXXFLAGS="-g -O2"
CGO_FFLAGS="-g -O2"
CGO_LDFLAGS="-g -O2"
PKG_CONFIG="pkg-config"
GOGCCFLAGS="-fPIC -m64 -pthread -fno-caret-diagnostics -Qunused-arguments -fmessage-length=0 -fdebug-prefix-map=/var/folders/4g/mwsmt1wj5qd5dwdhrshkfwzw0000gn/T/go-build534044314=/tmp/go-build -gno-record-gcc-switches -fno-common"```

</details>

<details><summary>Verbose output of running</summary>

```bash
$ golangci-lint run -v
INFO [config_reader] Config search paths: [./ /Users/fkautz/src/networkservicemesh /Users/fkautz/src /Users/fkautz /Users /] 
INFO [lintersdb] Active 10 linters: [deadcode errcheck gosimple govet ineffassign staticcheck structcheck typecheck unused varcheck] 
INFO [loader] Go packages loading at mode 575 (imports|exports_file|deps|files|name|types_sizes|compiled_files) took 148.047143ms 
INFO [runner/filename_unadjuster] Pre-built 0 adjustments in 252.334µs 
INFO [runner] processing took 2.757µs with stages: max_same_issues: 464ns, autogenerated_exclude: 446ns, nolint: 288ns, max_from_linter: 181ns, skip_dirs: 178ns, path_prettifier: 175ns, filename_unadjuster: 164ns, cgo: 129ns, identifier_marker: 115ns, skip_files: 112ns, source_code: 108ns, path_shortener: 105ns, diff: 101ns, max_per_file_from_linter: 50ns, uniq_by_line: 48ns, exclude: 47ns, exclude-rules: 46ns 
INFO [runner] linters took 79.834664ms with stages: goanalysis_metalinter: 49.130728ms, unused: 30.658834ms 
INFO File cache stats: 0 entries of total size 0B 
INFO Memory: 4 samples, avg is 70.1MB, max is 70.9MB 
INFO Execution took 243.209356ms                  ```

</details>

Network Service Mesh (a CNCF sandbox project) is currently using multiple subdirs each with their own go.mod and go.sum.

E.g.

./go.mod
./go.sum
forwarder/go.mod
forwarder/go.sum
k8s/go.mod
k8s/go.sum


When we run golangci-lint, only the root is loaded and all subdirs with their own go.mod are ignored. I assume this is to avoid analyzing vendored code. Unfortunately, this behavior prevents our repository from being fully analyzed in golangci.com.

Please add support for multiple subdirs to be listed recursively. We are ok adding these to the .golangci.yml if necessary.

Thanks for building such a great tool! Cheers!

Hi, I am using a private linter but it doesn't appear in the list of linters.

linters:
 enable:
   - unparam
   - misspell
   - godox
   - gocritic
   - scopelint
   - golint
   - unconvert
   - gofmt
   - exportloopref
   - govet
   - bodyclose
   - gosimple
   - goconst
   - gosec
   - logwercase

linters-settings:
  custom:
    logwercase:
      path: /home/aviscogl/go/bin/logwercase.so
      description: Analyze case of log message and WithField keys
      original-url: github.com/alexisvisco/logwercase

There is an option to known why a private linter is not added? https://golangci-lint.run/contributing/debug/ Does not help me ...

Welcome

  • Yes, I'm using a binary release within 2 latest major releases. Only such installations are supported.
  • Yes, I've searched similar issues on GitHub and didn't find any.
  • Yes, I've included all information below (version, config, etc).
  • Yes, I've tried with the standalone linter if available. (https://golangci-lint.run/usage/linters/)

Description of the problem

Hello getting the following error on my go project anytime I try to run golanci-lint on it. There was a very similar bug posted on this repo, but I think that this might be getting caused by a different issue. For background, this was correctly running yesterday, I did not change anything in the code, and my make command started failing with this issue. I know that's difficult to believe, but I even reverted to the last github push that I was confident ran "make" correctly and it started failing.

Some common errors I have checked: gcc is installed with version 9.4.0

Version of golangci-lint

$ golangci-lint --version
golangci-lint has version 1.50.0 built from 704109c6 on 2022-10-10T01:29:44Z

Configuration file

$ cat .golangci.yml
run:
  timeout: 5m
  modules-download-mode: readonly

linters-settings:
  gofmt:
    simplify: true
  goimports:
    local-prefixes: git-cluster.virtu.com/projects/SYS/repos/mattermost_plugins/compliance-plugin
  golint:
    min-confidence: 0
  govet:
    check-shadowing: true
    enable-all: true
    disable:
      - fieldalignment
  misspell:
    locale: US

linters:
  disable-all: true
  enable:
    - bodyclose
    #- deadcode
    - errcheck
    - gocritic
    - gofmt
    - goimports
    #- golint
    - revive
    - gosec
    - gosimple
    - govet
    - ineffassign
    - misspell
    - nakedret
    - staticcheck
    #- structcheck
    - stylecheck
    - typecheck
    - unconvert
    - unused
    #- varcheck
    - whitespace

issues:
  exclude-rules:
    - path: server/manifest.go
      linters:
        - unused
    - path: server/configuration.go
      linters:
        - unused
    - path: _test\.go
      linters:
        - bodyclose
        - scopelint # https://github.com/kyoh86/scopelint/issues/4

Go environment

$ go version && go env
go version go1.19.1 linux/amd64
GO111MODULE=""
GOARCH="amd64"
GOBIN=""
GOCACHE="/home/csmith/.cache/go-build"
GOENV="/home/csmith/.config/go/env"
GOEXE=""
GOEXPERIMENT=""
GOFLAGS=""
GOHOSTARCH="amd64"
GOHOSTOS="linux"
GOINSECURE=""
GOMODCACHE="/home/csmith/go/pkg/mod"
GONOPROXY=""
GONOSUMDB=""
GOOS="linux"
GOPATH="/home/csmith/go"
GOPRIVATE=""
GOPROXY="https://proxy.golang.org,direct"
GOROOT="/usr/local/go"
GOSUMDB="sum.golang.org"
GOTMPDIR=""
GOTOOLDIR="/usr/local/go/pkg/tool/linux_amd64"
GOVCS=""
GOVERSION="go1.19.1"
GCCGO="gccgo"
GOAMD64="v1"
AR="ar"
CC="gcc"
CXX="g++"
CGO_ENABLED="1"
GOMOD="/home/csmith/Code/goProjects/mattermost_plugins/com.compliance-plugin/go.mod"
GOWORK=""
CGO_CFLAGS="-g -O2"
CGO_CPPFLAGS=""
CGO_CXXFLAGS="-g -O2"
CGO_FFLAGS="-g -O2"
CGO_LDFLAGS="-g -O2"
PKG_CONFIG="pkg-config"
GOGCCFLAGS="-fPIC -m64 -pthread -Wl,--no-gc-sections -fmessage-length=0 -fdebug-prefix-map=/tmp/go-build899707641=/tmp/go-build -gno-record-gcc-switches"

Verbose output of running

$ golangci-lint cache clean
$ golangci-lint run -v
INFO [config_reader] Config search paths: [./ /home/csmith/Code/goProjects/mattermost_plugins/com.compliance-plugin /home/csmith/Code/goProjects/mattermost_plugins /home/csmith/Code/goProjects /home/csmith/Code /home/csmith /home / /home/csmith/snap/golangci-lint/99] 
INFO [config_reader] Used config file .golangci.yml 
INFO [lintersdb] Active 18 linters: [bodyclose errcheck gocritic gofmt goimports gosec gosimple govet ineffassign misspell nakedret revive staticcheck stylecheck typecheck unconvert unused whitespace] 
INFO [loader] Go packages loading at mode 575 (exports_file|types_sizes|files|imports|name|compiled_files|deps) took 474.589304ms 
INFO [runner/filename_unadjuster] Pre-built 0 adjustments in 1.681516ms 
INFO [linters_context/goanalysis] analyzers took 15.260912949s with top 10 stages: buildir: 11.056493377s, inspect: 951.68857ms, findcall: 781.12351ms, fact_deprecated: 621.707111ms, ctrlflow: 568.395668ms, printf: 498.239616ms, nilness: 227.431331ms, fact_purity: 220.532607ms, SA5012: 203.311228ms, typedness: 131.108218ms 
INFO [runner] Issues before processing: 10, after processing: 1 
INFO [runner] Processors filtering stat (out/in): autogenerated_exclude: 10/10, exclude-rules: 10/10, path_prettifier: 10/10, skip_files: 10/10, identifier_marker: 10/10, filename_unadjuster: 10/10, skip_dirs: 10/10, severity-rules: 1/1, path_prefixer: 1/1, sort_results: 1/1, source_code: 1/1, path_shortener: 1/1, nolint: 10/10, uniq_by_line: 1/10, diff: 1/1, max_per_file_from_linter: 1/1, max_same_issues: 1/1, max_from_linter: 1/1, cgo: 10/10, exclude: 10/10 
INFO [runner] processing took 619.364µs with stages: exclude-rules: 269.28µs, identifier_marker: 177.508µs, nolint: 54.749µs, path_prettifier: 48.073µs, skip_dirs: 40.124µs, source_code: 14.34µs, uniq_by_line: 3.479µs, cgo: 2.119µs, autogenerated_exclude: 1.66µs, filename_unadjuster: 1.609µs, max_same_issues: 1.54µs, max_per_file_from_linter: 927ns, max_from_linter: 922ns, path_shortener: 863ns, severity-rules: 538ns, sort_results: 515ns, skip_files: 373ns, diff: 372ns, exclude: 254ns, path_prefixer: 119ns 
INFO [runner] linters took 3.6568462s with stages: goanalysis_metalinter: 3.656135589s 
../../../../../../snap/golangci-lint/99/src/runtime/cgo/cgo.go:34:8: could not import C (cgo preprocessing failed) (typecheck)
import "C"
       ^
INFO File cache stats: 1 entries of total size 862B 
INFO Memory: 43 samples, avg is 354.5MB, max is 647.7MB 
INFO Execution took 4.140228964s  

Code example or link to a public repository

GO ?= $(shell command -v go 2> /dev/null)
NPM ?= $(shell command -v npm 2> /dev/null)
CURL ?= $(shell command -v curl 2> /dev/null)
MM_DEBUG ?=
MANIFEST_FILE ?= plugin.json
GOPATH ?= $(shell go env GOPATH)
GO_TEST_FLAGS ?= -race
GO_BUILD_FLAGS ?=
MM_UTILITIES_DIR ?= ../mattermost-utilities
DLV_DEBUG_PORT := 2346
DEFAULT_GOOS := $(shell go env GOOS)
DEFAULT_GOARCH := $(shell go env GOARCH)

export GO111MODULE=on

# You can include assets this directory into the bundle. This can be e.g. used to include profile pictures.
ASSETS_DIR ?= assets

## Define the default target (make all)
.PHONY: default
default: all

# Verify environment, and define PLUGIN_ID, PLUGIN_VERSION, HAS_SERVER and HAS_WEBAPP as needed.
include build/setup.mk
include build/legacy.mk

BUNDLE_NAME ?= $(PLUGIN_ID)-$(PLUGIN_VERSION).tar.gz

# Include custom makefile, if present
ifneq ($(wildcard build/custom.mk),)
	include build/custom.mk
endif

## Checks the code style, tests, builds and bundles the plugin.
.PHONY: all
all: check-style test dist

## Runs eslint and golangci-lint
.PHONY: check-style
check-style: webapp/node_modules
	@echo Checking for style guide compliance

ifneq ($(HAS_WEBAPP),)
	cd webapp && npm run lint
	cd webapp && npm run check-types
endif

ifneq ($(HAS_SERVER),)
	@if ! [ -x "$$(command -v golangci-lint)" ]; then \
		echo "golangci-lint is not installed. Please see https://github.com/golangci/golangci-lint#install for installation instructions."; \
		exit 1; \
	fi; \

	@echo Running golangci-lint
	golangci-lint run ./...
endif

## Builds the server, if it exists, for all supported architectures, unless MM_SERVICESETTINGS_ENABLEDEVELOPER is set.
.PHONY: server
server:
ifneq ($(HAS_SERVER),)
	mkdir -p server/dist;
ifeq ($(MM_DEBUG),)
ifneq ($(MM_SERVICESETTINGS_ENABLEDEVELOPER),)
	@echo Building plugin only for $(DEFAULT_GOOS)-$(DEFAULT_GOARCH) because MM_SERVICESETTINGS_ENABLEDEVELOPER is enabled
	cd server && $(GO) build $(GO_BUILD_FLAGS) -trimpath -o dist/plugin-$(DEFAULT_GOOS)-$(DEFAULT_GOARCH);
else
	cd server && env GOOS=linux GOARCH=amd64 $(GO) build $(GO_BUILD_FLAGS) -trimpath -o dist/plugin-linux-amd64;
	cd server && env GOOS=darwin GOARCH=amd64 $(GO) build $(GO_BUILD_FLAGS) -trimpath -o dist/plugin-darwin-amd64;
	cd server && env GOOS=windows GOARCH=amd64 $(GO) build $(GO_BUILD_FLAGS) -trimpath -o dist/plugin-windows-amd64.exe;
endif
else
	$(info DEBUG mode is on; to disable, unset MM_DEBUG)
ifneq ($(MM_SERVICESETTINGS_ENABLEDEVELOPER),)
	@echo Building plugin only for $(DEFAULT_GOOS)-$(DEFAULT_GOARCH) because MM_SERVICESETTINGS_ENABLEDEVELOPER is enabled
	cd server && $(GO) build $(GO_BUILD_FLAGS) -gcflags "all=-N -l" -trimpath -o dist/plugin-$(DEFAULT_GOOS)-$(DEFAULT_GOARCH);
else
	cd server && env GOOS=linux GOARCH=amd64 $(GO) build $(GO_BUILD_FLAGS) -gcflags "all=-N -l" -trimpath -o dist/plugin-linux-amd64;
	cd server && env GOOS=darwin GOARCH=amd64 $(GO) build $(GO_BUILD_FLAGS) -gcflags "all=-N -l" -trimpath -o dist/plugin-darwin-amd64;
	cd server && env GOOS=windows GOARCH=amd64 $(GO) build $(GO_BUILD_FLAGS) -gcflags "all=-N -l" -trimpath -o dist/plugin-windows-amd64.exe;
endif
endif
endif

## Ensures NPM dependencies are installed without having to run this all the time.
webapp/node_modules: $(wildcard webapp/package.json)
ifneq ($(HAS_WEBAPP),)
	cd webapp && $(NPM) install
	touch $@
endif

## Builds the webapp, if it exists.
.PHONY: webapp
webapp: webapp/node_modules
ifneq ($(HAS_WEBAPP),)
ifeq ($(MM_DEBUG),)
	cd webapp && $(NPM) run build;
else
	cd webapp && $(NPM) run debug;
endif
endif

## Generates a tar bundle of the plugin for install.
.PHONY: bundle
bundle:
	rm -rf dist/
	mkdir -p dist/$(PLUGIN_ID)
	cp $(MANIFEST_FILE) dist/$(PLUGIN_ID)/
ifneq ($(wildcard $(ASSETS_DIR)/.),)
	cp -r $(ASSETS_DIR) dist/$(PLUGIN_ID)/
endif
ifneq ($(HAS_PUBLIC),)
	cp -r public dist/$(PLUGIN_ID)/
endif
ifneq ($(HAS_SERVER),)
	mkdir -p dist/$(PLUGIN_ID)/server
	cp -r server/dist dist/$(PLUGIN_ID)/server/
endif
ifneq ($(HAS_WEBAPP),)
	mkdir -p dist/$(PLUGIN_ID)/webapp
	cp -r webapp/dist dist/$(PLUGIN_ID)/webapp/
endif
	cd dist && tar -cvzf $(BUNDLE_NAME) $(PLUGIN_ID)

	@echo plugin built at: dist/$(BUNDLE_NAME)

## Builds and bundles the plugin.
.PHONY: dist
dist:	server webapp bundle

## Builds and installs the plugin to a server.
.PHONY: deploy
deploy: dist
	./build/bin/pluginctl deploy $(PLUGIN_ID) dist/$(BUNDLE_NAME)

## Builds and installs the plugin to a server, updating the webapp automatically when changed.
.PHONY: watch
watch: server bundle
ifeq ($(MM_DEBUG),)
	cd webapp && $(NPM) run build:watch
else
	cd webapp && $(NPM) run debug:watch
endif

## Installs a previous built plugin with updated webpack assets to a server.
.PHONY: deploy-from-watch
deploy-from-watch: bundle
	./build/bin/pluginctl deploy $(PLUGIN_ID) dist/$(BUNDLE_NAME)

## Setup dlv for attaching, identifying the plugin PID for other targets.
.PHONY: setup-attach
setup-attach:
	$(eval PLUGIN_PID := $(shell ps aux | grep "plugins/${PLUGIN_ID}" | grep -v "grep" | awk -F " " '{print $$2}'))
	$(eval NUM_PID := $(shell echo -n ${PLUGIN_PID} | wc -w))

	@if [ ${NUM_PID} -gt 2 ]; then \
		echo "** There is more than 1 plugin process running. Run 'make kill reset' to restart just one."; \
		exit 1; \
	fi

## Check if setup-attach succeeded.
.PHONY: check-attach
check-attach:
	@if [ -z ${PLUGIN_PID} ]; then \
		echo "Could not find plugin PID; the plugin is not running. Exiting."; \
		exit 1; \
	else \
		echo "Located Plugin running with PID: ${PLUGIN_PID}"; \
	fi

## Attach dlv to an existing plugin instance.
.PHONY: attach
attach: setup-attach check-attach
	dlv attach ${PLUGIN_PID}

## Attach dlv to an existing plugin instance, exposing a headless instance on $DLV_DEBUG_PORT.
.PHONY: attach-headless
attach-headless: setup-attach check-attach
	dlv attach ${PLUGIN_PID} --listen :$(DLV_DEBUG_PORT) --headless=true --api-version=2 --accept-multiclient

## Detach dlv from an existing plugin instance, if previously attached.
.PHONY: detach
detach: setup-attach
	@DELVE_PID=$(shell ps aux | grep "dlv attach ${PLUGIN_PID}" | grep -v "grep" | awk -F " " '{print $$2}') && \
	if [ "$$DELVE_PID" -gt 0 ] > /dev/null 2>&1 ; then \
		echo "Located existing delve process running with PID: $$DELVE_PID. Killing." ; \
		kill -9 $$DELVE_PID ; \
	fi

## Runs any lints and unit tests defined for the server and webapp, if they exist.
.PHONY: test
test: webapp/node_modules
ifneq ($(HAS_SERVER),)
	$(GO) test -v $(GO_TEST_FLAGS) ./server/...
endif
ifneq ($(HAS_WEBAPP),)
	cd webapp && $(NPM) run test;
endif
ifneq ($(wildcard ./build/sync/plan/.),)
	cd ./build/sync && $(GO) test -v $(GO_TEST_FLAGS) ./...
endif

## Creates a coverage report for the server code.
.PHONY: coverage
coverage: webapp/node_modules
ifneq ($(HAS_SERVER),)
	$(GO) test $(GO_TEST_FLAGS) -coverprofile=server/coverage.txt ./server/...
	$(GO) tool cover -html=server/coverage.txt
endif

## Extract strings for translation from the source code.
.PHONY: i18n-extract
i18n-extract:
ifneq ($(HAS_WEBAPP),)
ifeq ($(HAS_MM_UTILITIES),)
	@echo "You must clone github.com/mattermost/mattermost-utilities repo in .. to use this command"
else
	cd $(MM_UTILITIES_DIR) && npm install && npm run babel && node mmjstool/build/index.js i18n extract-webapp --webapp-dir $(PWD)/webapp
endif
endif

## Disable the plugin.
.PHONY: disable
disable: detach
	./build/bin/pluginctl disable $(PLUGIN_ID)

## Enable the plugin.
.PHONY: enable
enable:
	./build/bin/pluginctl enable $(PLUGIN_ID)

## Reset the plugin, effectively disabling and re-enabling it on the server.
.PHONY: reset
reset: detach
	./build/bin/pluginctl reset $(PLUGIN_ID)

## Kill all instances of the plugin, detaching any existing dlv instance.
.PHONY: kill
kill: detach
	$(eval PLUGIN_PID := $(shell ps aux | grep "plugins/${PLUGIN_ID}" | grep -v "grep" | awk -F " " '{print $$2}'))

	@for PID in ${PLUGIN_PID}; do \
		echo "Killing plugin pid $$PID"; \
		kill -9 $$PID; \
	done; \

## Clean removes all build artifacts.
.PHONY: clean
clean:
	rm -fr dist/
ifneq ($(HAS_SERVER),)
	rm -fr server/coverage.txt
	rm -fr server/dist
endif
ifneq ($(HAS_WEBAPP),)
	rm -fr webapp/junit.xml
	rm -fr webapp/dist
	rm -fr webapp/node_modules
endif
	rm -fr build/bin/

## Sync directory with a starter template
sync:
ifndef STARTERTEMPLATE_PATH
	@echo STARTERTEMPLATE_PATH is not set.
	@echo Set STARTERTEMPLATE_PATH to a local clone of https://github.com/mattermost/mattermost-plugin-starter-template and retry.
	@exit 1
endif
	cd ${STARTERTEMPLATE_PATH} && go run ./build/sync/main.go ./build/sync/plan.yml $(PWD)

# Help documentation à la https://marmelab.com/blog/2016/02/29/auto-documented-makefile.html
help:
	@cat Makefile build/*.mk | grep -v '\.PHONY' |  grep -v '\help:' | grep -B1 -E '^[a-zA-Z0-9_.-]+:.*' | sed -e "s/:.*//" | sed -e "s/^## //" |  grep -v '\-\-' | sed '1!G;h;$$!d' | awk 'NR%2{printf "\033[36m%-30s\033[0m",$$0;next;}1' | sort

Your feature request related to a problem? Please describe.

I'm using the "fix" option, so golangci-lint automatically fixes issues when I run it.
But it's a problem for the nolintlint linter, because I use the allow-unused: false option.
Sometimes, when I'm working on lint issues, a //nolint comment doesn't match a lint issue. (but it should)
And with the "fix" option, the comment is automatically deleted.

It's also real problem while working on custom ruleguard rules.
While I'm building a rule, sometimes the syntax is not perfectly right, so the //nolint comments are deleted everywhere in my project.

Describe the solution you'd like.

I would like to be able to enable/disable the "fix" option per linter.

Describe alternatives you've considered.

We could also allow to disable "fix" for the nolintlint linter, but I think it's better to be able to enable/disable for all linters.

Additional context.

No response

Config:

linters:
  disable-all: true
  enable:
  - goimports
  - gci
  fast: false

linters-settings:
  goimports:
    local-prefixes: istio.io/

Input:

package main

import (
	"fmt"
	"istio.io/istio/pkg/test/framework/resource"
	"os"

	"istio.io/istio/pkg/test/framework/resource"
)

var (
	_ = resource.Cluster
	_ = fmt.Println
	_ = os.Stdout
)

Output:

package main

import (
	"fmt"
	"os"

	"istio.io/istio/pkg/test/framework/resource"
	"istio.io/istio/pkg/test/framework/resource"

	"istio.io/istio/pkg/test/framework/resource"
)

var (
	_ = resource.Cluster
	_ = fmt.Println
	_ = os.Stdout
)

Output seems nondeterministic

cc @daixiang0

Welcome

  • Yes, I'm using a binary release within 2 latest major releases. Only such installations are supported.
  • Yes, I've searched similar issues on GitHub and didn't find any.
  • Yes, I've included all information below (version, config, etc.).
  • Yes, I've tried with the standalone linter if available (e.g., gocritic, go vet, etc.). (https://golangci-lint.run/usage/linters/)

Description of the problem

Golangci-lint includes GCI 0.8.2. It has a bug that is fixed in the latest release. Upgrade please.

Version of golangci-lint

$ golangci-lint --version
golangci-lint has version v1.50.1 built from (unknown, mod sum: "h1:C829clMcZXEORakZlwpk7M4iDw2XiwxxKaG504SZ9zY=") on (unknown)

Your feature request related to a problem? Please describe.

is some case i don't want to disable all linter checks for expression by nolint:gocritic but only one rule hugeParam for example

Describe the solution you'd like.

add feature to write nolint directive for specific rule i propose the following syntax: nolint:linter_name:check_name as example nolint:gocritic:hugeParam

Describe alternatives you've considered.

~

Additional context.

No response

Your feature request related to a problem? Please describe.

This is a proposal to enhance the goimports linter to provide opinionated go import formatting rules. The linter could:

  1. Validate that go import statements are formatted according to the rules listed in golang/go#20818.
  2. In autofix mode, reformat the go import statements according to the opinionated rules.

Issue 20818 is still in ideation stage, but there is already a concrete implementation: https://github.com/rinchsan/gosimports is effectively a drop-in replacement for the goimport command, with additional opinionated rules to group/order go import statements.

Describe the solution you'd like.

I can see two ways to implement this proposal:

  1. Introduce a new gosimport linter that uses gosimport instead of goimport.
  2. Add a new config attribute to the existing goimports linter. The setting would be used to control which command to use, e.g. goimport or gosimport.

Option 2 seems to be better for users of the golangci-lint tool. There would be one linter to control go import formatting rules, one place to document what the formatting rules are. Also, it seems fairly straightforward to modify https://github.com/golangci/gofmt/tree/master/goimports to support either gosimport or goimport.

Describe alternatives you've considered.

This is a new feature. I'm not aware of the ability to control which go import formatting tool can be used.

Additional context.

Assuming the -local argument is the same for goimport and gosimport:

  1. The gosimport command may reformat code that was previously formatted with goimport.
  2. The goimport command does not reformat code that was previously formatted with gosimport.

Your feature request related to a problem? Please describe.

I can set the severity in golangci-lint's config to error or warning and vscode displays the linting the same way, seemingly as a warning.

I'd like to be able to separate out style suggestions from linting errors that indicate bugs... which is what severity is for, but I'm not sure it's getting output in the right format for vscode to understand.

Describe the solution you'd like.

I believe there's a way to format the output so that vscode can differentiate between errors and warnings.

Describe alternatives you've considered.

I don't know that there is an alternative.

Additional context.

No response