goenv: Read version from go.mod if .go-version is not available
Tracking version in .go-version is useful for scenarios where the user of goenv (who has goenv installed locally) is also a maintainer, or simply when the project has .go-version.
It would be great if goenv could also adapt to a scenario where project does not have .go-version for any reason, but the version can be read from go.mod file (go directive specifically):
module my-module
go 1.11
With that in mind, assuming that the version listed in go.mod is installed and there’s no .go-version, goenv could behave the same way as if there is .go-version and just switch to the relevant compatible Go version.
It’s worth noting that the two are not equivalent since go.mod only tracks minor versions (not patch versions), but I assume that goenv could just pick the latest compatible patch version that is installed?
About this issue
- Original URL
- State: closed
- Created 4 years ago
- Reactions: 13
- Comments: 17 (6 by maintainers)
Good idea, will look into it.
Hey @syndbg @ChronosMasterOfAllTime can you guys confirm the above understanding I have?
this would be a really nice feature since some projects don’t want to add a .go-version to not duplicate go.mod info
will need changes in: