go-version-file does not parse .mod files other than go.mod

Open
#736 1 comment 1 reaction 0 assignees View on GitHub

Maintainers usually reply within 5 days

@kaovilai is already working on this.

Since Mar 25, 2026.

  • #737 by @kaovilai — open

Assessment

Difficulty
2/5
Estimated time
1-3 hours
Newbie friendliness
48/100
Issue type
Bug
Clarity
Clearly specified
Activity status
Quiet
Tech stack
go, typescript
Domain
devops

Research direction

Start at parseGoVersionFile, especially the basename check described in the issue. Update handling so any .mod path uses Go module parsing, then verify that named module files resolve their toolchain or go directive rather than treating the full file contents as the version.

Written by the indexing model from the issue text.

Description

feature request

Description

When using go-version-file with a .mod file that is not literally named go.mod (e.g., golangci-lint.mod, tools.mod), the parseGoVersionFile function fails to extract the Go version correctly.

This is because the current implementation checks path.basename(versionFilePath) === 'go.mod', which only matches files named exactly go.mod. Any other .mod file falls through to the default case, which returns the entire file contents as the version string — causing version resolution to fail.

Use Case

A common Go community pattern is to use dedicated module files for tool dependencies. For example, golangci-lint recommends using a separate golangci-lint.mod file to pin the linter version independently from the project's go.mod.

Users should be able to use these files with go-version-file to install the correct Go version:

- uses: actions/setup-go@v6
  with:
    go-version-file: golangci-lint.mod

Current Behavior

parseGoVersionFile only recognizes:

  • go.mod (exact basename match)
  • go.work (exact basename match)
  • .tool-versions (exact basename match)

Any .mod file with a different name (e.g., golangci-lint.mod, tools.mod) is not parsed as a Go module file.

Expected Behavior

Any file ending in .mod should be parsed using the same Go module file logic (extracting toolchain or go directives), not just files named exactly go.mod.

Proposed Fix

Change the condition from:

path.basename(versionFilePath) === 'go.mod'

to:

versionFilePath.endsWith('.mod')

[!Note]
Responses generated with Claude

Dominant language
TypeScript
Stars
1.8k
Forks
684
Avg merge
12d 23h
Merged PRs (30d)
3

Getting set up

  • No Dockerfile or Docker Compose file
  • Has a pull request template
  • No contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from actions/setup-go

All issues in actions/setup-go

Similar issues

More TypeScript issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.