Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Docker version golangci/golangci-lint:v1.37.1 raise "no go files to analyze" #1784

Closed
4 tasks done
ybiquitous opened this issue Feb 26, 2021 · 3 comments
Closed
4 tasks done
Labels
question Further information is requested

Comments

@ybiquitous
Copy link

  • 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

The Docker version of golangci/golangci-lint:v1.37.1 raises the error Running error: context loading failed: no go files to analyze, while golangci/golangci-lint:v1.36.0 never raises any error.

See also #825 (comment).

Version of golangci-lint
$ docker run --rm -v $(pwd):/app -w /app golangci/golangci-lint:v1.37.1 golangci-lint version
golangci-lint has version v1.37.1 built from b39dbcd6 on 2021-02-20T11:59:15Z
Config file

No config file.

Go environment
$ docker run --rm -v $(pwd):/app -w /app golangci/golangci-lint:v1.37.1 go version
go version go1.16 linux/amd64

$ docker run --rm -v $(pwd):/app -w /app golangci/golangci-lint:v1.37.1 go env
GO111MODULE=""
GOARCH="amd64"
GOBIN=""
GOCACHE="/root/.cache/go-build"
GOENV="/root/.config/go/env"
GOEXE=""
GOFLAGS=""
GOHOSTARCH="amd64"
GOHOSTOS="linux"
GOINSECURE=""
GOMODCACHE="/go/pkg/mod"
GONOPROXY=""
GONOSUMDB=""
GOOS="linux"
GOPATH="/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.16"
GCCGO="gccgo"
AR="ar"
CC="gcc"
CXX="g++"
CGO_ENABLED="1"
GOMOD="/dev/null"
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-build2324239100=/tmp/go-build -gno-record-gcc-switches"
Verbose output of running
$ docker run --rm -v $(pwd):/app -w /app golangci/golangci-lint:v1.37.1 golangci-lint cache clean
$ docker run --rm -v $(pwd):/app -w /app golangci/golangci-lint:v1.37.1 golangci-lint run -v
level=info msg="[config_reader] Config search paths: [./ /app / /root]"
level=info msg="[lintersdb] Active 10 linters: [deadcode errcheck gosimple govet ineffassign staticcheck structcheck typecheck unused varcheck]"
level=info msg="[loader] Go packages loading at mode 575 (types_sizes|exports_file|name|files|imports|compiled_files|deps) took 44.4827ms"
level=error msg="Running error: context loading failed: no go files to analyze"
level=info msg="Memory: 2 samples, avg is 72.1MB, max is 72.1MB"
level=info msg="Execution took 50.8686ms"
Code example or link to a public repository

test.go:

package main

var unused int

func main() {
	print()
}

Only test.go file is present in the current directory:

$ ls -a .
.       ..      test.go
@ybiquitous ybiquitous added the bug Something isn't working label Feb 26, 2021
@ldez
Copy link
Member

ldez commented Feb 26, 2021

It's because the go.mod is missing

@ldez
Copy link
Member

ldez commented Feb 26, 2021

$ tree
.
└── foo.go

0 directories, 1 file
$ golangci-lint version
golangci-lint has version 1.37.1 built from b39dbcd6 on 2021-02-20T11:48:06Z
$ golangci-lint run
ERRO Running error: context loading failed: no go files to analyze 
$ tree
.
├── foo.go
└── go.mod

0 directories, 2 files
$ golangci-lint version
golangci-lint has version 1.37.1 built from b39dbcd6 on 2021-02-20T11:48:06Z
$ golangci-lint run
foo.go:3:5: `unused` is unused (deadcode)
var unused int
    ^

@ybiquitous
Copy link
Author

@ldez Thank you so much! I understand the behavior change. 👍

When I turn off GO111MODULE, I confirm golangci/golangci-lint:v1.37.1 works well.

$ docker run --env GO111MODULE=off --rm -v $(pwd):/app -w /app golangci/golangci-lint:v1.37.1 golangci-lint run
test.go:3:5: `unused` is unused (deadcode)
var unused int
    ^

/tmp/foo
$ docker run --env GO111MODULE=on --rm -v $(pwd):/app -w /app golangci/golangci-lint:v1.37.1 golangci-lint run
level=error msg="Running error: context loading failed: no go files to analyze"

I'll close this issue if no problems or concerns. Thanks!

@ldez ldez added question Further information is requested and removed bug Something isn't working labels Feb 26, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested
Projects
None yet
Development

No branches or pull requests

2 participants