golangci/golangci-lint · error

add to go.mod: %w

Error message

add to go.mod: %w

What it means

Wrapping error in Builder.Build for custom builds: the addToGoMod step (running 'go mod edit -replace' to add replace directives for plugins) failed. Common causes are a missing or malformed go.mod in the cloned repo or an invalid module path/version in the plugin configuration. The underlying command error is wrapped with %w.

Source

Thrown at pkg/commands/internal/builder.go:62

	b.log.Infof("Cloning golangci-lint repository")

	err := b.clone(ctx)
	if err != nil {
		return fmt.Errorf("clone golangci-lint: %w", err)
	}

	b.log.Infof("Adding plugin imports")

	err = b.updatePluginsFile()
	if err != nil {
		return fmt.Errorf("update plugin file: %w", err)
	}

	b.log.Infof("Adding replace directives")

	err = b.addToGoMod(ctx)
	if err != nil {
		return fmt.Errorf("add to go.mod: %w", err)
	}

	b.log.Infof("Running go mod tidy")

	err = b.goModTidy(ctx)
	if err != nil {
		return fmt.Errorf("go mod tidy: %w", err)
	}

	b.log.Infof("Building golangci-lint binary")

	binaryName := b.getBinaryName()

	err = b.goBuild(ctx, binaryName)
	if err != nil {
		return fmt.Errorf("build golangci-lint binary: %w", err)
	}

View on GitHub (pinned to ed7a235d2d)

Solutions

  1. Check the plugin's module path and version in the custom linter settings
  2. Verify the cloned golangci-lint repository has a valid go.mod
  3. Inspect logged go command output for the root cause
  4. Check network/Go toolchain availability
Defensive patterns

Strategy: retry

When it happens

Trigger: Thrown at pkg/commands/internal/builder.go:62 when the library encounters an invalid state.

Common situations: See trigger scenarios.


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