Skip to content

Golangci-lint is slow on a git worktree checkout as it does not share cache with parent repo #6430

@sheki

Description

@sheki

Welcome

How did you install golangci-lint?

go install

Your feature request related to a problem? Please describe

golangci-lint's package cache appears to be path-sensitive.

I'm seeing cache misses across identical checkouts/worktrees when the repo lives at a different absolute path, even with the same contents, config, Go version, and shared GOLANGCI_LINT_CACHE.

This matters more now because ephemeral git worktrees are increasingly common in agent-driven workflows.

Describe the solution you'd like

I would like different git workspaces to use the same cache

Describe alternatives you've considered

None

Additional context

This seems to be because:

  • internal/cache/cache.go includes both file path and file hash in the package key:
fmt.Fprintf(key, "file %s %x\n", f, h)
  • go/packages provides absolute CompiledGoFiles paths.

So identical repos at different absolute paths get different cache keys.

Minimal repro:

  1. Warm cache in worktree A.
  2. Create worktree B for the same commit at a different absolute path.
  3. Run the same golangci-lint run ... command.
  4. Package analysis runs again instead of reusing cache.

Supporter

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions