golangci/golangci-lint · error

custom version: %w

Error message

custom version: %w

What it means

Wrapping error in Builder.goBuild: createVersion failed to derive the version string for the custom binary (e.g. ldflags version assembly from the configured version failed). The build aborts before spawning 'go build'; the wrapped error names the exact parsing/generation failure.

Source

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

func (b Builder) goModTidy(ctx context.Context) error {
	cmd := exec.CommandContext(ctx, "go", "mod", "tidy")
	cmd.Dir = b.repo

	output, err := cmd.CombinedOutput()
	if err != nil {
		b.log.Warnf("%s", string(output))

		return fmt.Errorf("%s: %w", strings.Join(cmd.Args, " "), err)
	}

	return nil
}

func (b Builder) goBuild(ctx context.Context, binaryName string) error {
	version, err := b.createVersion(b.cfg.Version)
	if err != nil {
		return fmt.Errorf("custom version: %w", err)
	}

	b.log.Infof("version: %s", version)

	//nolint:gosec // the variable is sanitized.
	cmd := exec.CommandContext(ctx, "go", "build",
		"-ldflags",
		fmt.Sprintf("-s -w -X 'main.version=%s' -X 'main.date=%s'", version, time.Now().UTC().String()),
		"-o", binaryName,
		"./cmd/golangci-lint",
	)
	cmd.Dir = b.repo

	output, err := cmd.CombinedOutput()
	if err != nil {
		b.log.Warnf("%s", string(output))

		return fmt.Errorf("%s: %w", strings.Join(cmd.Args, " "), err)

View on GitHub (pinned to ed7a235d2d)

Solutions

  1. Check the configured custom version format
  2. Use a valid golangci-lint version or tag reference
  3. Inspect the wrapped error for the specific parsing failure
Defensive patterns

Strategy: validation

When it happens

Trigger: Thrown at pkg/commands/internal/builder.go:183 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/a086716643d7a25b. Report an issue: GitHub.