actions / actions/setup-go

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

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

Nobody has claimed this yet.

feature request
Dominant language
TypeScript
Stars
1.8k
Forks
673
Avg merge
6d 28m
Merged PRs (30d)
4

Description

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

Contributor guide

No contributing guide indexed for this repository

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.

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.

Assessment

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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.