"no export data": clearer error message
Closed this issue · 16 comments
Welcome
- Yes, I've searched similar issues on GitHub and didn't find any.
- I agree to follow this project's Code of Conduct
How did you install golangci-lint?
go install
Your feature request related to a problem? Please describe
"no export data" frequently obscures a more tractable error message - for example a type check failure or other build failure. Many issues reported on Github have this error message attached.
Describe the solution you'd like
If it is possible for goanalysis_metalinter to expose the underlying error, that would be very helpful. Failing that, if the metalinter could detect if the error message contains "no export data", and give a hint - "are you sure the project can be built with no errors?" - that would also help.
Describe alternatives you've considered
We could just keep presenting unclear error messages to end users
Additional context
No response
Supporter
- I am a sponsor through GitHub or OpenCollective
Hello,
There is no additional information we can provide when no export data error occurs.
Also, in most cases, this error is produced by the tooling and not golangci-lint itself.
"Are you sure the project can be built with no errors" is additional information - it lets the user know that the error message might be obscuring a deeper error.
It seems like a lot of users are running into this problem and would be helped by additional information. #1920
The error is not typed and, in most cases, it comes from code outside golangci-lint.
You can try to make any argumentum ad populum through our issues (even if this is not respectful), but the reality will not change.
Yes, I understand. You said there was "no additional information" but "it comes from code outside golangci-lint" is useful information that you are not presenting to users! You could include this information as part of the error message!
When node-gyp fails, npm includes info that says "this is not a problem with npm or node-gyp", which helps users figure out at least where to start looking.
I'm sure you don't enjoy responding to github issues/discussions which is why I'm confused why you want to continue fielding users questions about "no export data" even though they're typically unrelated to your project.
I neither enjoy nor "don't enjoy" responding to issues.
My answers are concise because I'm not a native speaker, and also because I don't like chit-chat or writing books as answers.
I think my answers were clear enough, but as you are insisting, I have already tried to improve "generic error messages" (#4536), but this is not as trivial as you might think, and doesn't have the consequences you might think.
So, my answer is still the same.
It's not just "go mod tidy" as is clear from reading through any of the discussion history.
I submitted #6058 with a potential fix to this issue.
I think I was not clear: the PR I referenced was just an example, not something related directly to this issue.
You are focused on your problem, and you don't understand.
I may reopen your AI-generated PR later, but for now, I'm exasperated.
You are focused on your problem, and you don't understand.
To be clear, this is not a problem that I ran into; I'm focused on the problem that engineers at my company are having using golangci-lint. The error presented by the linter is making it difficult to find the actual issue with their code. And a quick scan of the issues discussions page, to say nothing of e.g. the Gophers Slack channel, makes clear that many other users of golangci-lint are running into the same issue.
And what is also clear from reading, is that many people are mis-diagnosing the cause of 'no export data'; which is why I thought it was important to try to update the error message to make more clear where people should look and how to attack the problem.
I may reopen your AI-generated PR later, but for now, I'm exasperated.
It wasn't AI generated, and I probably spent an hour tweaking the logic, recompiling and rerunning, to try to get the error message to present in a clear way. Thanks.
I was analyzing your first PR because maybe it was interesting, and I missed something.
But you opened a 2nd PR... I don't understand this.
Why are your 2 PRs different?
Well, I wasn't sure why you closed the first one, and you immediately locked discussion, so I couldn't ask.
The second one was less "risky", in that it just involved appending to an existing error string, so I figured whatever problems you had with the first one, they might have been addressed by the second one.
I locked the discussion to have one place for discussion about the topic.
I through your PR was AI-generated mainly because of this comment: // Optionally skip test variants:, which is a typical AI comment.
But AI learned from humans.
I will reopen #6058
Can you share your test files? Or at least a minimal example?
I created a test case (and modified the PR content), the result is:
$ ./golangci-lint run
WARN [runner] Can't run linter goanalysis_metalinter: inspect: failed to load package : could not load export data: no export data for "github.com/denis-tingaikin/go-header", maybe because of error(s) in imported package(s):
error in package "github.com/denis-tingaikin/go-header": missing go.sum entry for module providing package github.com/denis-tingaikin/go-header (imported by github.com/golangci/sandbox); to add:
go get github.com/golangci/sandbox
ERRO Running error: can't run linter goanalysis_metalinter
inspect: failed to load package : could not load export data: no export data for "github.com/denis-tingaikin/go-header", maybe because of error(s) in imported package(s):
error in package "github.com/denis-tingaikin/go-header": missing go.sum entry for module providing package github.com/denis-tingaikin/go-header (imported by github.com/golangci/sandbox); to add:
go get github.com/golangci/sandboxThere are more details, but the details are unexpected: using go get github.com/golangci/sandbox inside the module github.com/golangci/sandbox is weird.
The simple solution, in this case, is to run go mod tidy.
And after the go mod tidy, I have an expected typecheck error.
I'm curious to have another example.
I tried to reproduce the error related to the error inside the PR description.
.
├── fake
│ ├── go.mod
│ └── tag.go
├── go.mod
├── go.sum
└── main.go
main.go
package main
import (
"github.com/golangci/sandbox/fake"
)
func main() {
fake.Foo()
}go.mod
module github.com/golangci/sandbox
go 1.24.0
require (
github.com/golangci/sandbox/fake v0.0.0-00010101000000-000000000000
)
replace github.com/golangci/sandbox/fake => ./fake./fake/tag.go
package fake
import "slices"
type Tag struct{}
func Foo() {
}
func tagCompare(a, b Tag) bool {
return true
}
func Bar(tags []Tag, ) {
slices.IsSortedFunc(tags, tagCompare)
}./fake/go.mod
module github.com/golangci/sandbox/fake
go 1.24.0$ ./golangci-lint run
main.go:6:2: could not import github.com/golangci/sandbox/fake (-: # github.com/golangci/sandbox/fake
fake/tag.go:16:28: in call to slices.IsSortedFunc, type func(a Tag, b Tag) bool of tagCompare does not match inferred type func(a Tag, b Tag) int for func(a E, b E) int) (typecheck)
"github.com/golangci/sandbox/fake"
^
1 issues:
* typecheck: 1I have typecheck errors but no no export data.
I also tried to use vendor and modify the content to get the error, but still no no export data error:
$ ./golangci-lint run
main.go:6:2: could not import github.com/golangci/sandbox/fake (-: # github.com/golangci/sandbox/fake
vendor/github.com/golangci/sandbox/fake/tag.go:16:28: in call to slices.IsSortedFunc, type func(a Tag, b Tag) bool of tagCompare does not match inferred type func(a Tag, b Tag) int for func(a E, b E) int) (typecheck)
"github.com/golangci/sandbox/fake"
^
1 issues:
* typecheck: 1So for now, I can produce no export data error only when the go.mod is not synchronized, and then the solution is go mod tidy.
I found a way to reproduce by cleaning some caches and performing a lot of retries.