Skip to content

Conversation

ldez
Copy link
Member

@ldez ldez commented Sep 6, 2025

This is not trivial to explain (even to reproduce the behavior), but in summary, golangci-lint should not return the error fmt.Errorf("could not load export data: %w", err) because it bypasses the typecheck report system.

When typecheck report system is bypassed, a log is printed instead of a report.

This is why there is:

$ golangci-lint run 
WARN [runner] Can't run linter goanalysis_metalinter: buildir: failed to load package fake: could not load export data: no export data for "github.com/golangci/sandbox/fake" 
ERRO Running error: can't run linter goanalysis_metalinter
buildir: failed to load package fake: could not load export data: no export data for "github.com/golangci/sandbox/fake"

instead of

$ ./golangci-lint run 
main.go:6:2: could not import github.com/golangci/sandbox/fake (-: # github.com/golangci/sandbox/fake
fake/tag.go:14:35: 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: 1

Behind this bug, there is another bug (I fixed it), it feels the same, but it's different internally:

Before:

$ golangci-lint run        
WARN [runner] Can't run linter goanalysis_metalinter: buildir: failed to load package : could not load export data: no export data for "github.com/denis-tingaikin/go-header"
ERRO Running error: can't run linter goanalysis_metalinter
buildir: failed to load package : could not load export data: no export data for "github.com/denis-tingaikin/go-header" 

After:

$ ./golangci-lint run
main.go:6:11: could not import github.com/denis-tingaikin/go-header (main.go:6:2: 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) (typecheck)                                                                                                                                                                               
        goheader "github.com/denis-tingaikin/go-header"
                 ^
1 issues:
* typecheck: 1

Fixes #6056

Related to #3996, #4630, #4912, #4964, #5037, #5051, #5184, #5428, #5437
#2489, #2191, #2751, #3363, #4829

@ldez ldez added this to the v2-unreleased milestone Sep 6, 2025
@ldez ldez added bug Something isn't working area: core labels Sep 6, 2025
@ldez ldez marked this pull request as draft September 6, 2025 10:07
@ldez ldez marked this pull request as ready for review September 6, 2025 11:52
@ldez ldez force-pushed the fix/no-export-data branch 3 times, most recently from 9255eac to 2445695 Compare September 6, 2025 12:23
@ldez ldez force-pushed the fix/no-export-data branch from 2445695 to 8d8148e Compare September 6, 2025 12:24
@ldez ldez force-pushed the fix/no-export-data branch from 8d8148e to 5e596bb Compare September 6, 2025 12:26
@ldez ldez changed the title fix: no export data must always be handle as a typecheck error fix: no export data must always be handled as a typecheck error Sep 6, 2025
@ldez ldez merged commit 88ef93e into golangci:main Sep 7, 2025
18 checks passed
@ldez ldez deleted the fix/no-export-data branch September 7, 2025 20:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area: core bug Something isn't working
Projects
None yet
Development

Successfully merging this pull request may close these issues.

"no export data": clearer error message
2 participants