Skip to content

context loading failed: no go files to analyze #825

Closed
@rmilejcz

Description

@rmilejcz

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    questionFurther information is requested

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions