golangci/golangci-lint · error

no export data for %q

Error message

no export data for %q

What it means

A package in the export-data loading pass has an empty ExportFile path, so golangci-lint cannot read its compiled type information. Export data is required to reconstruct the types.Package without recompiling from source.

Source

Thrown at pkg/goanalysis/runner_loadingpackage.go:245

	// Call NewPackage directly with explicit name.
	// This avoids skew between golist and go/types when the files'
	// package declarations are inconsistent.
	// Subtle: we populate all Types fields with an empty Package
	// before loading export data so that export data processing
	// never has to create a types.Package for an indirect dependency,
	// which would then require that such created packages be explicitly
	// inserted back into the Import graph as a final step after export data loading.
	pkg.Types = types.NewPackage(pkg.PkgPath, pkg.Name)

	pkg.IllTyped = true
	for path, pkg := range pkg.Imports {
		if pkg.Types == nil {
			return fmt.Errorf("dependency %q hasn't been loaded yet", path)
		}
	}

	if pkg.ExportFile == "" {
		return fmt.Errorf("no export data for %q", pkg.ID)
	}

	f, err := os.Open(pkg.ExportFile)
	if err != nil {
		return err
	}
	defer f.Close()

	r, err := gcexportdata.NewReader(f)
	if err != nil {
		return err
	}

	view := make(map[string]*types.Package)  // view seen by gcexportdata
	seen := make(map[*packages.Package]bool) // all visited packages
	var visit func(pkgs map[string]*packages.Package)
	visit = func(pkgs map[string]*packages.Package) {
		for _, pkg := range pkgs {

View on GitHub (pinned to ed7a235d2d)

Solutions

  1. Ensure the package actually builds: `go build ./...` with the same tags used by the linter
  2. Align build tags/GOOS/GOARCH between the lint invocation and the build
  3. Update golangci-lint and x/tools (export data loading fixes ship there)
  4. Run `go clean -cache` to force fresh export data generation

Example fix

// before: lint with tags
// golangci-lint run
// after: pass the same build tags
golangci-lint run --build-tags=integration
Defensive patterns

Strategy: validation

Validate before calling

// ensure all packages build and export data exists before lint
exec.Command("go", "build", "./...").Run()

Try / catch

// surface hint: check build tags alignment
if strings.Contains(err.Error(), "no export data") {
    log.Print("align --build-tags/GOOS with your build; rebuild deps")
}

Prevention

When it happens

Trigger: loadFromExportData finds pkg.ExportFile == "" — the package has no export data file, typically because it was never built or is a synthetic/no-op package (e.g. unsafe, or a package excluded from the build).

Common situations: Package not compiled because of build constraints/tags mismatch; go/packages driver returning incomplete responses; linting with custom build tags where some deps are excluded.

Related errors


AI-assisted analysis of golangci/golangci-lint@ed7a235d2d (2026-09-02). Data as JSON: /api/errors/227bf05fdbe4f105. Report an issue: GitHub.