goenv
goenv copied to clipboard
[WIP][HELP NEEDED] If `.go-version` is missing, fallback on `go.mod`
Context #121
Hello, this addresses a long standing request that I think it would make many people happy about goenv. The ability to fallback from .go-version to go.mod.
I think this PR isn't ready, as I was only able to figure out how to interject through the "discovery" of the .go-version file, and read the version instead from go.mod if the former is missing.
Now, I think I might need some help to figure out the rest, and also to decide on the approach.
How do we handle the version from go.mod?
One option could be that we rely on the fact that, whatever is the current installed version of goenv, it knows locally what is the latest minor version of Go. So, for example, if in my go.mod I have:
go 1.17
goenv could look into it's list of known versions and:
- use if already present
- suggest to install it if not
This is just a suggestion: I'm completely open to better, more "implementable" ideas.
Issues running tests
I have read through the CONTRIBUTING.md doc, and I was unable to run tests. I keep getting this error:
↳ make test
set -e
/bin/sh: -c: line 1: syntax error: unexpected end of file
if [ -d "/Users/idemarino/Workspaces/opensource/goenv/bats-core" ]; then
make: *** [bats] Error 2
I tried a few things but none seemed to help.
For context, I'm on:
- macOS 12.4 "Monterey"
- Apple M1 Pro (ARM64)
$BASH_VERSION=5.1.16(1)-release
Hey @syndbg - Is this project still active and you are just busy, or should I consider a fork? I'd really like to stick to contribution for now: I totally understand that maintaining stuff is sometimes super busy and hard to keep up.
Let me know.
I have an idea on how to implement the whole thing, by using the version in go.mod and picking the latest known patch version that matches the minor version.
But testing is still broken for me, and I can't figure out what am I missing.
Thank you
Hey @syndbg - Is this project still active and you are just busy, or should I consider a fork?
I'd really like to stick to contribution for now: I totally understand that maintaining stuff is sometimes super busy and hard to keep up.
Let me know.
I have an idea on how to implement the whole thing, by using the version in go.mod and picking the latest known patch version that matches the minor version.
But testing is still broken for me, and I can't figure out what am I missing.
Thank you
I see it as mostly feature complete and don't do much to extend it features-wise. If something breaks, I'd fix it.
I'm also open to adding people with Write permissions as contributors/maintainers. If you want, I can add you. ^^
Other than that I'm looking at PRs. This month I'm taking a sabbatical break and I won't be actively looking at anything.
Issues running tests
I have read through the [CONTRIBUTING.md](https://github.com/syndbg/goenv/blob/master/CONTRIBUTING.md) doc, and I was unable to run tests. I keep getting this error:
↳ make test
set -e
/bin/sh: -c: line 1: syntax error: unexpected end of file
if [ -d "/Users/idemarino/Workspaces/opensource/goenv/bats-core" ]; then
make: *** [bats] Error 2
I tried a few things but none seemed to help.
For context, I'm on:
macOS 12.4 "Monterey"
Apple M1 Pro (ARM64)
$BASH_VERSION=5.1.16(1)-release
Hmm, that's strange. Just ran it on my machine.
272 tests, 0 failures
-------
$ uname -a
Linux DESKTOP-AKE17NH 5.4.91-microsoft-standard-WSL2+ #4 SMP Fri Mar 12 12:47:57 EET 2021 x86_64 x86_64 x86_64 GNU/Linux
---------
$ bash --version
bash: GNU bash, version 5.1.8(1)-release (x86_64-pc-linux-gnu)
What is failing tho is the goenv-go-build tests. But those aren't really important for what you're trying to do.
41 tests, 4 failures
make: *** [Makefile:26: run-goenv-go-build-tests] Error 1
I can only speculate it might be something ARM-specific, but I don't really use ARM hardware myself to be able to test it out. :/
Any traction on this PR? It seems like a good idea
Hey @EfChouTR - I'd love to make some progress, but I need help with that issue I describe above. Since I opened the PR I haven't had time to dig deeper, but if you have suggestions on what might be causing the tests to fail, I'd give it a go soon.
@detro I made a PR for your branch; all the unit tests are fixed, and I merged the latest master changes into my branch, which will bring your PR up to date.
As long as tests pass, I can see this being merged.
One thing I'd suggest before merging it is to introduce it behind a feature flag, so that we can test it out in "isolation". E.g GOENV_GOMOD_VERSION_ENABLE=1/0, default = 0 (off). That we can make sure it's not a major change for existing users. It'll eventually be changed to 1 (on) by default as we gain "confidence".
As long as tests pass, I can see this being merged.
One thing I'd suggest before merging it is to introduce it behind a feature flag, so that we can test it out in "isolation". E.g
GOENV_GOMOD_VERSION_ENABLE=1/0, default =0(off). That we can make sure it's not a major change for existing users. It'll eventually be changed to1(on) by default as we gain "confidence".
@syndbg
The following PR into @detro's fork should resolve all failing tests and add new tests for new feature + feature flag
detro/goenv#1
Once this is merged we should re-run the tests
I just merged @ChronosMasterOfAllTime PR into my branch, so it contains the additional "default off" ENV VAR, but also some formatting/spacing fixes too. I don't know if this is ok or not @syndbg , but they looked nice improvements.
@ChronosMasterOfAllTime went the extra mile and even provided tests for the new feature, awesomesauce!
I unfortunately haven't had time to actually check out the branch and try to run the tests locally again: that will have to wait for Monday, when I might have more free time.
Very excited for this progress, and I can't thank @ChronosMasterOfAllTime enough (nice username btw :D)
I just merged @ChronosMasterOfAllTime PR into my branch, so it contains the additional "default off" ENV VAR, but also some formatting/spacing fixes too. I don't know if this is ok or not @syndbg , but they looked nice improvements.
@ChronosMasterOfAllTime went the extra mile and even provided tests for the new feature, awesomesauce!
I unfortunately haven't had time to actually check out the branch and try to run the tests locally again: that will have to wait for Monday, when I might have more free time.
Very excited for this progress, and I can't thank @ChronosMasterOfAllTime enough (nice username btw :D)
Thanks! Don't forget to remove the WIP and HELP NEEDED from the PR title 😁