-
-
Notifications
You must be signed in to change notification settings - Fork 1.4k
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
context loading failed: no go files to analyze #825
Comments
Disregard, for those getting a similar error message make sure you can build your project. I was able to figure out the issue by running
If possible, the error message |
thank you, I think we need to fix error message |
Hi, I'm having the same issue even in latest version 1.21.0, any ideas what could be the issue? Thanks. |
The only advice I could give is to make sure your code is error free, run |
This is tripping up our code formatting, as we've moved that to GolangCI Lint (running Goimports would normally clean up any import paths that don't exist (e.g. from code that has been removed), however when running in GolangCI Lint, this gives the |
We had to downgrade to 1.17 to make it to work and about goimports we had to disable it and use it standalone without golangci lint. Maybe we are doing something wrong but at least we found a way. I think the linter doesn't play nice with a multi go modules repository in our case, as we are using a mono repository with multiple go modules in it one per each service |
For me it was connected to unupdated vendoring directory with enabled readonly mode. |
golangci/golangci-lint#825 Signed-off-by: meows <[email protected]>
In wtfutil/wtf#895 I used |
Hi,
golangci-lint cache clean && go clean -modcache -cache -i
golangci-lint run -v --timeout=5s |
Over time we have accumulated a disturbing number of ways to run the Go command, each of which supported slightly different features and workarounds. Combine all of them. This unavoidably introduces some changes in debug logging behavior; I think we should try to fix them incrementally and consistently. Updates golang/go#37368. Change-Id: I664ca8685bf247a226be3cb807789c2fcddf233d Reviewed-on: https://go-review.googlesource.com/c/tools/+/220737 Run-TryBot: Heschi Kreinick <[email protected]> Reviewed-by: Rebecca Stambler <[email protected]>
In case of timeouts of go/packages loading we could return such error. Relates: #825
On Go 1.17.1 it worked OK. After I upgrade to
|
golangci-lint fails with a context error (maybe golangci/golangci-lint#825) Using the opportunity to bump the helm version, which was ~2 years old.
This answer should be promoted since it clearly addresses that the issue is actually caused by error resides in your project, not that golangci-lint cannot find any go files. |
The main reason is that your code failed to compile, maybe you forget to run I also got this problem with the output when running
When i add the command
So, i realized that i need download it's dependencies and compile it successfully. |
Just hit this because I needed to run |
In my case the command below helped:
|
i can confirm this solution:
Error message is not very helpful. |
We had a race condition in our CI where However, even an additional $ ls -al go.mod go.sum
-rw-rw-rw- 1 root root 6123 Nov 8 19:36 go.mod
-rw-rw-rw- 1 root root 200250 Nov 8 19:36 go.sum
$ ls -al .go/pkg/mod || go mod tidy
total 72
drwxr-xr-x 18 root root 4096 Nov 8 19:31 .
drwxrwxrwx 3 root root 4096 Nov 8 19:36 ..
drwxr-xr-x 4 root root 4096 Nov 8 19:31 cache
drwxr-xr-x 11 root root 4096 Nov 8 19:31 cosmossdk.io
drwxr-xr-x 3 root root 4096 Nov 8 19:31 filippo.io
drwxr-xr-x 95 root root 4096 Nov 8 19:31 github.com
drwxr-xr-x 3 root root 4096 Nov 8 19:31 gitlab.com
drwxr-xr-x 6 root root 4096 Nov 8 19:31 go.blockdaemon.com
drwxr-xr-x 3 root root 4096 Nov 8 19:31 go.etcd.io
drwxr-xr-x 6 root root 4096 Nov 8 19:31 go.uber.org
drwxr-xr-x 3 root root 4096 Nov 8 19:31 golang.org
drwxr-xr-x 6 root root 4096 Nov 8 19:31 google.golang.org
drwxr-xr-x 6 root root 4096 Nov 8 19:31 gopkg.in
drwxr-xr-x 3 root root 4096 Nov 8 19:31 gotest.tools
dr-xr-xr-x 14 root root 4096 Nov 8 19:31 [email protected]+incompatible
drwxr-xr-x 3 root root 4096 Nov 8 19:31 nhooyr.io
drwxr-xr-x 3 root root 4096 Nov 8 19:31 pgregory.net
drwxr-xr-x 3 root root 4096 Nov 8 19:31 sigs.k8s.io
$ golangci-lint --version
golangci-lint has version v1.55.2 built with go1.21.3 from e3c2265f on 2023-11-03T13:27:48Z
$ golangci-lint -v run --timeout 10m --issues-exit-code 0
level=info msg="[config_reader] Config search paths: [./ XXX / /root]"
level=info msg="[lintersdb] Active 6 linters: [errcheck gosimple govet ineffassign staticcheck unused]"
level=info msg="[loader] Go packages loading at mode 575 (types_sizes|compiled_files|exports_file|imports|name|deps|files) took 1.328024256s"
level=error msg="Running error: context loading failed: no go files to analyze"
level=info msg="Memory: 15 samples, avg is 22.8MB, max is 22.8MB"
level=info msg="Execution took 1.333339766s" |
We just had a problem in CI where, through a long chain of quirks, the source tree was incomplete... and we didn't verify it built before running lint. Hilarity ensued (with an error like can't run linter goanalysis_metalinter: inspect: failed to load package foo: could not load export data: no export data for...). Could golangci-lint check somehow that the project had built? In CI, this could be rather helpful. |
When obtaining go modules fails, golangci-lint will report the error "no go files to analyze". The error message is inaccurate.
|
You have to use |
To reproduce this error, these conditions are required:
|
This should never happen: tag re-creation is strictly forbidden by the Go modules system. |
I have regularly run
golangci-lint run
from the root of my directory without issue for the last several weeks. Today, after successfully runninggolangci-lint run
, I fixed all the reported issues and then ran the command in the same terminal but I got the output:even though nothing seems to have changed. The project structure is basically 60 or so folders, each having a
main.go
, amain_test.go
and two auto generated files which are ignored bygolangci-lint
. If I specify a package it lints without issue e.g.:runs the linter on that package without any error.
Version of golangci-lint
Config file
Go environment
Verbose output of running
The text was updated successfully, but these errors were encountered: