golangci/golangci-lint · error

makezero linter failed on file %q: %w

Error message

makezero linter failed on file %q: %w

What it means

The makezero linter's Run step wraps any error returned by the underlying makezero analyzer for a specific file, including the file name, and aborts the whole pass. It indicates makezero could not analyze the file's AST/types, typically a bug in makezero or an unexpected AST node, not a user code defect.

Source

Thrown at pkg/golinters/makezero/makezero.go:36

			Run: func(pass *analysis.Pass) (any, error) {
				err := runMakeZero(pass, settings)
				if err != nil {
					return nil, err
				}

				return nil, nil
			},
		}).
		WithLoadMode(goanalysis.LoadModeTypesInfo)
}

func runMakeZero(pass *analysis.Pass, settings *config.MakezeroSettings) error {
	zero := makezero.NewLinter(settings.Always)

	for _, file := range pass.Files {
		hints, err := zero.Run(pass.Fset, pass.TypesInfo, file)
		if err != nil {
			return fmt.Errorf("makezero linter failed on file %q: %w", file.Name.String(), err)
		}

		for _, hint := range hints {
			pass.Report(analysis.Diagnostic{
				Pos:     hint.Pos(),
				Message: hint.Details(),
			})
		}
	}

	return nil
}

View on GitHub (pinned to ed7a235d2d)

Solutions

  1. Update golangci-lint to the latest version — this often fixes makezero panics/errors on edge-case files.
  2. Disable makezero or exclude the offending file via skip-files / issues.exclude-files.
  3. Report the wrapped inner error (the %w cause) upstream to shazow/makezero or golangci-lint if reproducible.
  4. Disable type-checking-dependent analysis issues by fixing build errors in the package so pass.TypesInfo is complete.

Example fix

// .golangci.yml
// before
linters:
  enable: [makezero]
// after
linters:
  enable: [makezero]
issues:
  exclude-files:
    - path/to/problematic_file.go
Defensive patterns

Strategy: try-catch

Validate before calling

if err := types.Pass.Check(pkgPath, info); err != nil { /* fix compile errors first so TypesInfo is complete */ }

Try / catch

issues, err := runMakeZero(pass, settings)
if err != nil {
    var inner error
    if errors.As(err, &inner) { log.Printf("makezero failed: %v", inner) }
    // fall back: disable makezero for this run
}

Prevention

When it happens

Trigger: makezero.NewLinter(...).Run(pass.Fset, pass.TypesInfo, file) returns a non-nil error while iterating pass.Files in runMakeZero, e.g. on a file with constructs makezero's ast inspection cannot handle.

Common situations: Running golangci-lint with makezero enabled on codebases with unusual generated code; version mismatches between golangci-lint and the vendored makezero library; types info unavailable or partially populated for cgo/generated files.

Related errors


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