You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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:
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.
Description
When using
go-version-filewith a.modfile that is not literally namedgo.mod(e.g.,golangci-lint.mod,tools.mod), theparseGoVersionFilefunction fails to extract the Go version correctly.This is because the current implementation checks
path.basename(versionFilePath) === 'go.mod', which only matches files named exactlygo.mod. Any other.modfile 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.modfile to pin the linter version independently from the project'sgo.mod.Users should be able to use these files with
go-version-fileto install the correct Go version:Current Behavior
parseGoVersionFileonly recognizes:go.mod(exact basename match)go.work(exact basename match).tool-versions(exact basename match)Any
.modfile 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
.modshould be parsed using the same Go module file logic (extractingtoolchainorgodirectives), not just files named exactlygo.mod.Proposed Fix
Change the condition from:
to:
Note
Responses generated with Claude