go-nv / goenv Goto Github PK
View Code? Open in Web Editor NEW:blue_car: Like pyenv and rbenv, but for Go.
Home Page: https://github.com/go-nv/goenv
License: MIT License
:blue_car: Like pyenv and rbenv, but for Go.
Home Page: https://github.com/go-nv/goenv
License: MIT License
I have installed goenv using brew on my mac.
goenv shows that I have got version 1.23.3 installed.
goenv install --list only shows till go version 1.12beta1.
Since there are have been a lot of go versions released after 1.12, is there a way that we can update the list to include all the newer versions of go?
I am using visual studio code as main Go IDE.
It requires GOROOT to be set to be able to find the standard library.
goenv init
does not seems to set it at launch.
May be would it be good also to have a command we can trigger to reset the GOROOT
according to the current location.
When running $ goenv install 1.15.6
on an RPi4 (arm64) the program fails silently without installing anything. Any clues? Thank you...
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?
Hi there, I'm running the HEAD
version of goenv and the env var GOENV_GOPATH_PREFIX
does not seem to work. More specifically, the env var is not set, goenv will automatically manage and update the GOPATH
to be $HOME/go/$VERSION
however, if the env var is set the GOPATH
is set to the GOENV_GOPATH_PREFIX
only and the version is not included.
I can't figure out if it's a bug or something misconfigured in my system. Any idea?
Thanks a lot for your help.
goenv is cool, I would like to use its docker image to build my project so that I can manage different go versions. Is there an official docker image for this?
I tried to submit a PR to add your project but it doesn't meet some requirements:
Please provide package links to:
Make sure that you've checked the boxes below before you submit PR:
Hi!
Thanks for the great lib!
After some trial and error.. I am still stuck on the GOROOT problem
when using the go env
, my $GOROOT
is correctly set as expected.
However, when using echo $GOROOT
it output an empty string.
I use the git way to install goenv
I have the following on the bottom of my bash_profile
export GOPATH="$HOME/projects"
export GOENV_ROOT="$HOME/.goenv"
export PATH="$GOENV_ROOT/bin:$PATH"
eval "$(goenv init -)"
I install goenv
from brew
Normally I use pyenv virtualenv 3.7.2 myprojectname
to create the virtual environment
When I tried with goenv
which I expected to see the same result
$ goenv virtualenv 1.11.4 try-go
goenv: no such command `virtualenv'
How do I create a dedicate virtual environment for my project?
Add support for 1.13.15 for patching CVE-2020-16845
Can INSTALL.md accept a complete refactoring at this point, or should we keep adding exceptions and notes for e.g. zsh and Ubuntu? I know that the existing INSTALL.md is pretty much a direct port of the one from pyenv; I'm wondering if we're purposely staying with that template, or if we can stray. I ask because I may have another note to add to it...
On Ubuntu (or any other distro that points BASH_ENV at .bashrc), if you follow the instructions in INSTALL.md, it currently tells you to put the goenv init -
command in .bash_profile to prevent a loop. This can create a problem though, because if you do that, the goenv init -
command isn't run when starting a subshell from editors or IDEs.
I ran into this problem when using vim-go, for instance, because vim-go needs to be able to shell out to run guru
etc. When the subshell is started, it doesn't run goenv init -
, so GOPATH may not be set right, depending on what else is in your dotfiles.
Here's a general fix: Rather than call goenv init -
from .bash_profile as INSTALL.md currently recommends, I instead put this at the bottom of my .bashrc:
if [ -z "$GOENV_INIT_DONE" ]
then
export GOENV_INIT_DONE=1
export GOENV_ROOT="$HOME/.goenv"
export PATH="$GOENV_ROOT/bin:$PATH"
eval "$(goenv init -)"
export PATH="$GOROOT/bin:$PATH"
export PATH="$GOPATH/bin:$PATH"
fi
For me, this fixed the problem I had, and I wonder if this sort of fix would prevent many of the problems others run into. So rephrasing the question above -- should we add this sort of thing as yet another Ubuntu note, in addition to the existing Ubuntu and zsh notes, or should INSTALL.md be reworked completely?
For instance, should we perhaps provide the above code as a script that is sourced from .bashrc, rather than continue with the multiple appends we're doing now?
Latest goenv installed on freebsd 13.0 could install go 1.15.3, but cannot set go versions.
[hoge@hoge ~/.anyenv/envs/goenv]$ goenv install 1.15.3
Downloading go1.15.3.freebsd-amd64.tar.gz...
-> https://golang.org/dl/go1.15.3.freebsd-amd64.tar.gz
Installing Go Freebsd 64bit 1.15.3...
Installed Go Freebsd 64bit 1.15.3 to /home/hoge/.anyenv/envs/goenv/versions/1.15.3
[hoge@hoge ~/.anyenv/envs/goenv]$ goenv global 1.15.3
[hoge@hoge ~/.anyenv/envs/goenv]$ goenv rehash
sed: 1: "s/^\s*\(\S\+\).*/\1/": RE error: trailing backslash (\)
[hoge@hoge ~/.anyenv/envs/goenv]$ goenv versions
sed: 1: "s/^\s*\(\S\+\).*/\1/": RE error: trailing backslash (\)
1.15.3
How can I fix it?
Hi,
I've a question, after I installed goenv for 1.14.1,
and I saw inside the GOPATH that managed by goenv.
There are directories like src and pkg,
but why bin directory doesn't created?
Thanks
Okay so, I'm new to Go, and found goenv since I'm familiar with rbenv, pyenv, etc.
I'm having trouble getting stuff installed with go get
commands that have binaries to actually ever say anything other than "command not found".
Forgive me if this has already been discussed, I did browse the closed issues and the open issues but couldn't find exactly this.
I'm assuming this works a lot like rbenv, etc.
I use goenv
as I would any other.
goenv install 1.8.3
goenv global 1.8.3
I install dependencies such as revel
and dep
with:
go get -u github.com/golang/dep/cmd/dep
go get github.com/revel/revel
goenv rehash
and I still am getting:
-bash: dep: command not found
-bash: revel: command not found
In my ~/.bash_profile on MacOS Sierra:
export GOENV_ROOT="$HOME/.goenv"
export PATH="$GOENV_ROOT/bin:$PATH"
eval "$(goenv init -)"
export GOPATH="$HOME/go"
As seen above, I even tried something from another closed issue for setting GOPATH=
to ~/go as default. But no dice.
Any tips on this?
Followed all the instructions but this doesn't seem to work on alpine (3.8, 3.9 or 3.10).
go and godoc give command not found (gofmt works).
➜ .goenv git:(master) ls cache
go1.12.4.darwin-amd64.tar.gz
➜ .goenv git:(master) goenv install 1.12.4
Downloading go1.12.4.darwin-amd64.tar.gz...
-> https://dl.google.com/go/go1.12.4.darwin-amd64.tar.gz
^C%
it still needs to download the archive file
gone version: 2.00beta9
This one's related to the INSTALL.md refactoring in #98, but I'm entering it as a separate issue because it's a pretty bad security vulnerability that probably needs to be dealt with sooner.
We ought to be telling users to put $GOPATH/bin at the end of $PATH, not the beginning. Right now, in text inherited from the pyenv
INSTALL.md, we're telling users to put $GOPATH/bin at the beginning. By doing that, we're potentially allowing anyone with a github ID to silently supersede any standard UNIX/Linux utility on machines using goenv.
In my case, I recently installed an innocent package, and noticed a while later that goenv init -
was failing. After a very confusing afternoon of troubleshooting, I finally realized, with some disbelief, that this sort
at the bottom of goenv-commands
was returning empty stdout regardless of stdin: https://github.com/syndbg/goenv/blob/256f7c85e56dde3ee64aa268737bc07f1484ac1f/libexec/goenv-commands#L44 It turned out that the package I'd earlier installed had dropped a binary named sort
into $GOPATH/bin. The whole saga is described in gory detail over in emirpasic/gods#123. Thankfully, @emirpasic responded quickly and accepted my pull request, but many packages aren't going to be that well-maintained.
In retrospect, this vulnerability is pretty obvious, but it didn't hit me until now just what Go's decentralized package distribution means when coupled with the way go get
silently adds things to your $PATH. A malicious package could do quite a lot of damage and/or go undetected for a long time.
For reference, the Go docs have $GOPATH/bin at the end of $PATH: https://tip.golang.org/doc/code.html#GOPATH
I am just trying out the goenv tool and wanted to check if there's an equivalent to the gvm pkgsets for isolating the package dependencies for different GoLang projects.
We can handle this by changing the GOPATH environment variable to the new Project workspace everytime we work on a project, but this is quite annoying.
Though Go has the official GoModules to isolate dependencies between projects, i think the pkgsets allows for complete isolation of the package and module dependencies by having a separate folders for projects sharing the same version of Go; this also allows programmers to switch between multiple Go Projects simultaneously without having to update GOPATH.
So, I would like to understand if such a thing is supported with goenv. I could not figure it out from the documentation. Please let me know if this is possible with goenv
Thanks
Go2 already has the minimum available version, hope to support it.
ref https://go.googlesource.com/go/+/refs/heads/dev.go2go/README.go2go.md
Golang.org is not accessible in some areas like china. And https://golang.org/dl/sone.pkg
will eventually jump to https://dl.google.com/go/sone.pkg
to perform the download.
Can we replace golang.org
with dl.google.com/go
Or provide an option to replace the prefix of the download url?
https://golang.org/dl/go1.14.6.linux-amd64.tar.gz -> https://dl.google.com/go/go1.14.6.linux-amd64.tar.gz
prefix = https://golang.org/dl or https://dl.google.com/go
$prefix//go1.14.6.linux-amd64.tar.gz
ref:
gwf in china https://en.wikipedia.org/wiki/Great_Firewall
golang/go#8870
https://blog.golang.org/hello-china
GOENV_DISABLE_GOPATH=1
is working. also GOENV_DISABLE_GOROOT
.
When running goenv, it appends the version to GOPATH.
However it is common to keep one's source in the src directory without a version prefix.
When GOPATH is already set, goenv should append instead of overriding it.
On the latest master (20/3/19) it seems that the exported environment variable GOPATH is not passed to go as running go env
gives /home/$user/go/$goversion
and not whatever $GOROOT
is set to.
I noticed goenv 1.14 was released https://golang.org/doc/go1.14 but goenv install --list
only has 1.14beta1. Could you add add 1.14.1?
Since 7449cb5 GOROOT is not being set upon init.
Installed version 1.23.3 via Homebrew on Mac OS X 10.14.6
After following installation instructions (adding goenv init
etc to .zshrc) and restarting shell, $GOPATH is empty.
When new version of go is release like go1.15rc1,we must imp plugins。can make choice to install custom verion with dl link?
Thanks.
There's no feedback or indicator that a binary isn't available for Linux armv7l when running goenv install
. At the very minimum, if a binary for the CPU architecture isn't found, there should be some response for that.
Additionally, the armv6l builds will work on armv7l, so it should download those instead.
For a "system" go, goenv prefix
outputs "/usr/local" but should be "/usr/local/opt/go/libexec".
Environment:
Temporarily, I solve this by adding these lines to my .bash_profile
:
if [ $(goenv version-name) == "system" ]
then
export GOROOT="/usr/local/opt/go/libexec"
else
export GOROOT="$(goenv prefix)"
fi
Hi, I'm using github.com/go-swagger/go-swagger
which depends on golang.org/x/tools/go/loader
.
The way I intend to use this tool is to run swagger generate spec
, but it fails:
/Users/matias.anaya/go/swagger-test/main.go:13:8: could not import net/http (cannot find package "net/http" in any of:
/usr/local/go/src/net/http (from $GOROOT)
/Users/matias.anaya/go/src/net/http (from $GOPATH))
/Users/matias.anaya/go/swagger-test/main.go:16:2: undeclared name: http
couldn't load packages due to errors: .
The work around is to run GOROOT=$(go env GOROOT) swagger generate spec
.
Is this expected? Is there a fix for my setup, the tool or goenv
that I'm missing?
Thanks in advance :)
This would allow us to update the build installed via homebrew.
Hi there,
I notice that there haven't been any 1.X releases lately in favour of 2.0.0 beta releases. Are we likely to see any more 1.X releases coming out? Is a 2.0.0 stable release likely to drop soon?
If there aren't likely to be any new 1.X releases would it be appropriate if we updated the Homebrew references to point to the 2.x betas? I'd love for my team to update to Go 1.12, but ideally we can avoid manually managing our goenv installations.
https://github.com/Homebrew/homebrew-core/blob/master/Formula/goenv.rb
I'm less familiar how this project operates, but is there intention in the future to decouple go-build and goenv releases to allow for go version bumps independent of toolchain changes to goenv itself?
Hi there!
I'd like to submit the updated release to https://github.com/Homebrew/homebrew-core.
We can get this release via homebrew by using --head
in the meantime, but would prefer something less scary :)
https://github.com/syndbg/goenv/releases
Thanks.
Does goenv set it based on currently selected version or just set it to the same location for all versions?
Likely announcing soon, the binaries have become available today: https://golang.org/dl/#go1.16
while it feels like bug in go, to omit .0 from version, I believe you should match version numbers exactly. Integration tests that put version into .go-version and try to parse that version back from go version
output do fail due to this mismatch.
goenv install 1.11
go-build: definition not found: 1.11
The following versions contain `1.11' in the name:
1.11.0
1.11beta2
1.11beta3
1.11rc1
1.11rc2
echo '1.11.0' > .go-version
go version
go version go1.11 linux/amd64
When printing out the version numbers they don't come out in semver order
$ goenv versions
1.10.2
* 1.11.0 (set by /home/hughest/.goenv/version)
1.5.4
Using sort fixes it but I don't know if this is a linux extension to sort or cross platform
$ goenv versions |sort --version-sort
1.5.4
1.10.2
* 1.11.0 (set by /home/hughest/.goenv/version)
goenv install --list shows 1.12beta1 as the last go version available to install in goenv
How do i install go version >= 1.13.x in goenv ?
Hi, I just install goenv success installed but got this error:
$ go --version
goenv: 'go' command not found
in my .zshrc
file
export GOENV_ROOT="$HOME/.goenv"
export PATH="$GOENV_ROOT/bin:$PATH"
export GOPATH="/Volumes/MACHDD/workspace-go"
export PATH="$PATH:$GOPATH/bin"
eval "$(goenv init -)"
export PATH="$GOROOT/bin:$PATH"
Any solution on this problem?
Thanks
$ html=$(curl https://golang.org/dl/)
# tarball & shasum
$ echo $html | perl -pe 's/<[^>]*>//g' | perl -pe 's/(go[1-9]\.)/\n\1/g' | grep -E '(darwin|linux|freebsd).*(386|amd64).*\.tar\.gz[ ]*Archive' | sed 's/[ ]*$//' | perl -pe 's/^(go[1-9].*\.tar\.gz).* ([0-9a-f]*)$/\1#\2/' | sort | uniq
...
go1.8.3.darwin-amd64.tar.gz#f20b92bc7d4ab22aa18270087c478a74463bd64a893a94264434a38a4b167c05
go1.8.3.freebsd-386.tar.gz#d301cc7c2b8b0ccb384ac564531beee8220727fd27ca190b92031a2e3e230224
go1.8.3.freebsd-amd64.tar.gz#1bf5f076d48609012fe01b95e2a58e71e56719a04d576fe3484a216ad4b9c495
go1.8.3.linux-386.tar.gz#ff4895eb68fb1daaec41c540602e8bb4c1e8bb2f0e7017367171913fc9995ed2
go1.8.3.linux-amd64.tar.gz#1862f4c3d3907e59b04a757cfda0ea7aa9ef39274af99a784f5be843c80c6772
go1.8.darwin-amd64.tar.gz#6fdc9f98b76a28655a8770a1fc8197acd8ef746dd4d8a60589ce19604ba2a120
go1.8.freebsd-386.tar.gz#9965b73686fcf82a7d002e75b30d4125cc9f47906c1e2b2f0ef036a6665f0348
go1.8.freebsd-amd64.tar.gz#e750579f390fe5c95de30c2a52d7ce88250cf971c435323373d22bfab8a63431
go1.8.linux-386.tar.gz#8f618dc8b01c2e53e639a38d780645b8424e671e292c7b518248022205d6a448
go1.8.linux-amd64.tar.gz#53ab94104ee3923e228a2cb2116e5e462ad3ebaeea06ff04463479d7f12d27ca
go1.9beta2.darwin-amd64.tar.gz#07e25fa6e290e46bee8ee2d836d79c3f5a35917b013ecf686d7e761631524de2
go1.9beta2.freebsd-386.tar.gz#27283b4b96fe9f566d53e26b4ce7db10cd4d2d5bfdd37914c19fe44e4c39bdb3
go1.9beta2.freebsd-amd64.tar.gz#86cdd9759802d1b985978b4158f6e91cfae8b43a52fc99219dfc6402ee356036
go1.9beta2.linux-386.tar.gz#b06f1ef695560d687c94ebd83a0c2f6d1adfa37121ddd14d361816eaa2f00d44
go1.9beta2.linux-amd64.tar.gz#023f778f063d2234e7c95f572a92298b307807693f7e045a88c90ecd7a08f29d
# versions
$ echo $html | perl -pe 's/<[^>]*>//g' | perl -pe 's/(go[1-9]\.)/\n\1/g' | grep -E '(darwin|linux|freebsd).*(386|amd64).*\.tar\.gz[ ]*Archive' | sed 's/[ ]*$//' | perl -pe 's/^(go[1-9].*\.tar\.gz).* ([0-9a-f]*)$/\1#\2/' | perl -pe 's/^go([1-9].*)\.(darwin|linux|freebsd).*/\1/' | sort | uniq
1.2.2
1.3
1.3.1
1.3.2
1.3.3
1.4
1.4.1
1.4.2
1.4.3
1.5
1.5.1
1.5.2
1.5.3
1.5.4
1.6
1.6.1
1.6.2
1.6.3
1.6.4
1.7
1.7.1
1.7.3
1.7.4
1.7.5
1.7.6
1.8
1.8.1
1.8.2
1.8.3
1.9beta2
I'm not sure why goenv doesn't do anything here, on aarch64. I've installed both rbenv and pyenv too, and pyenv is installing Python 3.8.0 for me on there right now, and I am pretty sure rbenv would be doing the same.
I tried running goenv install with verbose both on and off, and nothing gets printed out to the console.
Here's the goenv section of .bashrc
:
export GOENV_ROOT="$HOME/.goenv"
export PATH="$GOENV_ROOT/bin:$PATH"
eval "$(goenv init -)"
export PATH="$GOROOT/bin:$PATH"
export PATH="$PATH:$GOPATH/bin"
First off, thanks for the great tool. I've run into a few problems since upgrading from version 1.X brew install --HEAD goenv
Previously I had the following in my .bash_profile
, which seemed to work ok
if which goenv > /dev/null; then eval "$(goenv init -)"; fi
export GOPATH="$HOME/go"
export PATH="$GOROOT/bin:$PATH"
export PATH="$GOPATH/bin:$PATH"
The docs for GOENV_DISABLE_GOPATH
specify:
It's recommend that you use this (as set to 0) to avoid mixing multiple versions of golang packages at GOPATH when using different versions of golang. See #72 (comment)
So now I have the following in my .bash_profile
and I'm leaving goenv
to manage my GOPATH
if which goenv > /dev/null; then eval "$(goenv init -)"; fi
export PATH="$GOROOT/bin:$PATH"
export PATH="$GOPATH/bin:$PATH"
Currently my projects are all in the $HOME/go/src
dir:
/Users/gw/go/src/gitlab.com/GrahamWalters/project-a (1.11.4)
/Users/gw/go/src/gitlab.com/GrahamWalters/project-b (1.12.7)
$HOME/go/version/src
?/Users/gw/go/1.11.4/src/gitlab.com/GrahamWalters/project-a (1.11.4)
/Users/gw/go/1.12.7/src/gitlab.com/GrahamWalters/project-b (1.12.7)
/Users/gw/go/src/gitlab.com/GrahamWalters/project-a (1.11.4)
/Users/gw/go/src/gitlab.com/GrahamWalters/project-b (1.12.7)
/Users/gw/go/1.11.4/bin/project-a
/Users/gw/go/1.12.7/bin/project-b
I installed golang
and goenv
from homebrew:
brew install golang goenv
This is part of my .zshrc
:
export GOPATH="$HOME/.go"
export PATH="$HOME/.goenv/shims:$PATH"
eval "$(goenv init -)"
After that GOROOT
is set to /usr/local
(see #22).
When I try to install anything, e. g. go get github.com/ncw/rclone
, it outputs many error messages like:
package xxx: unrecognized import path "xxx" (import path does not begin with hostname)
If I unset GOROOT
then everything is installing fine as before #22.
Also if I switch to another golang version:
goenv install 1.7.5
goenv global 1.7.5
goenv rehash
then GOROOT
is not set, but I thought that it's managed by goenv.
goenv only searches $GOENV_ROOT for plugins
, even though the install location often differs, causing packagers to move the plugin to the share
directory (pyenv example), and breaking when installed with tools like basher
.
I think both locations should be searched if the plugin is to remain embedded.
Note: This solution is not applicable to rbenv because rbenv does not bundle the build plugin
Hi, I know many people are using homebrew to install goenv which relies on a tag and release system. Would you consider to adopt a more formal tagging procedure so that Homebrew formula could rely on and get updated.
Thank you.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.