Skip to content

No recursive directory scan when one of the arg is a .go file #1081

@danmx

Description

@danmx

I've noticed that when trying to scan selected directories and .go files to scan instead of using ./... I get an error:

$ golangci-lint run main.go pkg/...
ERRO Running error: context loading failed: failed to load program with go/packages: -: named files must be .go files: ./pkg/...

but when I just scan directories everything works fine:

golangci-lint run cmd/... pkg/... . && echo $?
0
Version of golangci-lint
$ golangci-lint --version
golangci-lint has version 1.26.0 built from 6bd10d0 on 2020-05-01T15:26:22Z
Config file
$ cat .golangci.yml
run:
  deadline: 5m
  tests: true
  skip-dirs:
  - .git
  - bazel-*
  - tools
  - docs
linters-settings:
  # depguard:
  #   list-type: blacklist
  #   packages:
  #     # logging is allowed only by logutils.Log, logrus
  #     # is allowed to use only in logutils package
  #     - github.com/sirupsen/logrus
  #   packages-with-error-message:
  #     - github.com/sirupsen/logrus: "logging is allowed only by logutils.Log"
  dupl:
    threshold: 100
  # funlen:
  #   lines: 100
  #   statements: 50
  goconst:
    min-len: 2
    min-occurrences: 2
  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: 15
  goimports:
    local-prefixes: github.com/danmx/sigil
  golint:
    min-confidence: 0
  gomnd:
    settings:
      mnd:
        checks: argument,case,condition,return,operation,assign
  govet:
    check-shadowing: true
  # lll:
  #   line-length: 100
  maligned:
    suggest-new: true
  misspell:
    locale: UK

linters:
  disable-all: true
  enable:
    - bodyclose
    - deadcode
    - depguard
    - dogsled
    - dupl
    - errcheck
    # - funlen
    # - gochecknoinits
    - goconst
    - gocritic
    - gocyclo
    - gofmt
    - goimports
    - golint
    - gomnd
    - goprintffuncname
    - gosec
    - gosimple
    - govet
    - ineffassign
    - interfacer
    # - lll
    - misspell
    - nakedret
    # - rowserrcheck
    - scopelint
    - staticcheck
    - structcheck
    - stylecheck
    - typecheck
    - unconvert
    - unparam
    - unused
    - varcheck
    - whitespace
Go environment
$ go version && go env
go version go1.14.2 darwin/amd64

GO111MODULE="on"
GOARCH="amd64"
GOBIN=""
GOCACHE="/Users/danieliziourov/Library/Caches/go-build"
GOENV="/Users/danieliziourov/Library/Application Support/go/env"
GOEXE=""
GOFLAGS=""
GOHOSTARCH="amd64"
GOHOSTOS="darwin"
GOINSECURE=""
GONOPROXY=""
GONOSUMDB=""
GOOS="darwin"
GOPATH="/Users/danieliziourov/go"
GOPRIVATE=""
GOPROXY="https://proxy.golang.org,direct"
GOROOT="/usr/local/Cellar/go/1.14.2_1/libexec"
GOSUMDB="sum.golang.org"
GOTMPDIR=""
GOTOOLDIR="/usr/local/Cellar/go/1.14.2_1/libexec/pkg/tool/darwin_amd64"
GCCGO="gccgo"
AR="ar"
CC="clang"
CXX="clang++"
CGO_ENABLED="0"
GOMOD="/Users/danieliziourov/git/public/danmx/sigil/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 -fno-caret-diagnostics -Qunused-arguments -fmessage-length=0 -fdebug-prefix-map=/var/folders/sy/lqws73317qsdcchxfd0xdy140000gp/T/go-build378746692=/tmp/go-build -gno-record-gcc-switches -fno-common"
Verbose output of running
$ golangci-lint cache clean
$ golangci-lint run -v
INFO [config_reader] Config search paths: [./ /Users/danieliziourov/git/public/danmx/sigil /Users/danieliziourov/git/public/danmx /Users/danieliziourov/git/public /Users/danieliziourov/git /Users/danieliziourov /Users /]
INFO [config_reader] Used config file .golangci.yml
INFO [lintersdb] Active 31 linters: [bodyclose deadcode depguard dogsled dupl errcheck goconst gocritic gocyclo gofmt goimports golint gomnd goprintffuncname gosec gosimple govet ineffassign interfacer misspell nakedret scopelint staticcheck structcheck stylecheck typecheck unconvert unparam unused varcheck whitespace]
INFO [lintersdb] Active 31 linters: [bodyclose deadcode depguard dogsled dupl errcheck goconst gocritic gocyclo gofmt goimports golint gomnd goprintffuncname gosec gosimple govet ineffassign interfacer misspell nakedret scopelint staticcheck structcheck stylecheck typecheck unconvert unparam unused varcheck whitespace]
INFO [loader] Go packages loading at mode 575 (compiled_files|deps|files|imports|exports_file|name|types_sizes) took 667.380191ms
INFO [runner/enabledLinters] Active 31 linters: [bodyclose deadcode depguard dogsled dupl errcheck goconst gocritic gocyclo gofmt goimports golint gomnd goprintffuncname gosec gosimple govet ineffassign interfacer misspell nakedret scopelint staticcheck structcheck stylecheck typecheck unconvert unparam unused varcheck whitespace]
INFO [runner/filename_unadjuster] Pre-built 0 adjustments in 1.471968ms
INFO [runner/goanalysis_metalinter/goanalysis] analyzers took 13.545470697s with top 10 stages: buildssa: 8.843422265s, fact_deprecated: 594.013891ms, inspect: 508.637436ms, printf: 489.334017ms, ctrlflow: 485.319842ms, fact_purity: 435.440637ms, goimports: 286.340722ms, dupl: 249.962754ms, gocritic: 243.854117ms, gosec: 188.269735ms
INFO [runner/unused/goanalysis] analyzers took 310.859249ms with top 10 stages: buildssa: 274.940064ms, U1000: 35.919185ms
INFO [runner] Issues before processing: 63, after processing: 0
INFO [runner] Processors filtering stat (out/in): nolint: 0/2, skip_dirs: 63/63, autogenerated_exclude: 33/63, identifier_marker: 33/33, filename_unadjuster: 63/63, skip_files: 63/63, exclude-rules: 2/2, exclude: 2/33, cgo: 63/63, path_prettifier: 63/63
INFO [runner] processing took 29.652262ms with stages: path_prettifier: 25.215498ms, autogenerated_exclude: 1.677424ms, exclude: 770.848µs, skip_dirs: 689.098µs, nolint: 678.447µs, identifier_marker: 591.042µs, cgo: 21.72µs, filename_unadjuster: 5.274µs, max_same_issues: 875ns, uniq_by_line: 453ns, skip_files: 338ns, diff: 265ns, exclude-rules: 261ns, max_from_linter: 232ns, source_code: 187ns, path_shortener: 153ns, max_per_file_from_linter: 147ns
INFO [runner] linters took 3.925129365s with stages: goanalysis_metalinter: 3.543967994s, unused: 351.423081ms
INFO File cache stats: 21 entries of total size 78.1KiB
INFO Memory: 48 samples, avg is 339.7MB, max is 541.1MB
INFO Execution took 4.616693116s

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions