Go Version Manager

gvm

Build Status

By Josh Bussdieker (jbuss, jaja, jbussdieker) while working at Moovweb

Currently lovingly maintained by Benjamin Knigge

Pull requests and other any other contributions would be very much appreciated.

GVM provides an interface to manage Go versions.

Features

  • Install/Uninstall Go versions with gvm install [tag] where tag is "60.3", "go1", "weekly.2011-11-08", or "tip"
  • List added/removed files in GOROOT with gvm diff
  • Manage GOPATHs with gvm pkgset [create/use/delete] [name]. Use --local as name to manage repository under local path (/path/to/repo/.gvm_local).
  • List latest release tags with gvm listall. Use --all to list weekly as well.
  • Cache a clean copy of the latest Go source for multiple version installs.
  • Link project directories into GOPATH

Background

When we started developing in Go mismatched dependencies and API changes plauged our build process and made it extremely difficult to merge with other peoples changes.

After nuking my entire GOROOT several times and rebuilding I decided to come up with a tool to oversee the process. It eventually evolved into what gvm is today.

Installing

To install:

bash < <(curl -s -S -L https://raw.githubusercontent.com/moovweb/gvm/master/binscripts/gvm-installer)

Or if you are using zsh just change bash with zsh

Installing Go

gvm install go1.4
gvm use go1.4 [--default]

Once this is done Go will be in the path and ready to use. $GOROOT and $GOPATH are set automatically.

Additional options can be specified when installing Go:

Usage: gvm install [version] [options]
    -s,  --source=SOURCE      Install Go from specified source.
    -n,  --name=NAME          Override the default name for this version.
    -pb, --with-protobuf      Install Go protocol buffers.
    -b,  --with-build-tools   Install package build tools.
    -B,  --binary             Only install from binary.
         --prefer-binary      Attempt a binary install, falling back to source.
    -h,  --help               Display this message.

A Note on Compiling Go 1.5+

Go 1.5+ removed the C compilers from the toolchain and replaced them with one written in Go. Obviously, this creates a bootstrapping problem if you don't already have a working Go install. In order to compile Go 1.5+, make sure Go 1.4 is installed first.

gvm install go1.4 -B
gvm use go1.4
export GOROOT_BOOTSTRAP=$GOROOT
gvm install go1.5

List Go Versions

To list all installed Go versions (The current version is prefixed with "=>"):

gvm list

To list all Go versions available for download:

gvm listall

Uninstalling

To completely remove gvm and all installed Go versions and packages:

gvm implode

If that doesn't work see the troubleshooting steps at the bottom of this page.

Mac OS X Requirements

xcode-select --install
brew update
brew install mercurial

Linux Requirements

Debian/Ubuntu

sudo apt-get install curl git mercurial make binutils bison gcc build-essential

Redhat/Centos

sudo yum install curl
sudo yum install git
sudo yum install make
sudo yum install bison
sudo yum install gcc
sudo yum install glibc-devel

FreeBSD Requirements

sudo pkg_add -r bash
sudo pkg_add -r git
sudo pkg_add -r mercurial

Vendoring Native Code and Dependencies

GVM supports vendoring package set-specific native code and related dependencies, which is useful if you need to qualify a new configuration or version of one of these dependencies against a last-known-good version in an isolated manner. Such behavior is critical to maintaining good release engineering and production environment hygiene.

As a convenience matter, GVM will furnish the following environment variables to aid in this manner if you want to decouple your work from what the operating system provides:

  1. ${GVM_OVERLAY_PREFIX} functions in a manner akin to a root directory hierarchy suitable for auto{conf,make,tools} where it could be passed in to ./configure --prefix=${GVM_OVERLAY_PREFIX} and not conflict with any existing operating system artifacts and hermetically be used by your workspace. This is suitable to use with C{PP,XX}FLAGS and LDFLAGS, but you will have to manage these yourself, since each tool that uses them is different.

  2. ${PATH} includes ${GVM_OVERLAY_PREFIX}/bin so that any tools you manually install will reside there, available for you.

  3. ${LD_LIBRARY_PATH} includes ${GVM_OVERLAY_PREFIX}/lib so that any runtime library searching can be fulfilled there on FreeBSD and Linux.

  4. ${DYLD_LIBRARY_PATH} includes ${GVM_OVERLAY_PREFIX}/lib so that any runtime library searching can be fulfilled there on Mac OS X.

  5. ${PKG_CONFIG_PATH} includes ${GVM_OVERLAY_PREFIX}/lib/pkgconfig so that pkg-config can automatically resolve any vendored dependencies.

Recipe for success:

gvm use go1.1
gvm pkgset use current-known-good
# Let's assume that this includes some C headers and native libraries, which
# Go's CGO facility wraps for us.  Let's assume that these native
# dependencies are at version V.
gvm pkgset create trial-next-version
# Let's assume that V+1 has come along and you want to safely trial it in
# your workspace.
gvm pkgset use trial-next-version
# Do your work here replicating current-known-good from above, but install
# V+1 into ${GVM_OVERLAY_PREFIX}.

See examples/native for a working example.

Troubleshooting

Sometimes especially during upgrades the state of gvm's files can get mixed up. This is mostly true for upgrade from older version than 0.0.8. Changes are slowing down and a LTR is imminent. But for now rm -rf ~/.gvm will always remove gvm. Stay tuned!

Gitter

Owner
Moovweb
Moovweb XDN delivers unparalleled site speeds via progressive web apps with server-side rendering, auto AMP creation, and CDN-as-code.
Moovweb
Comments
  • Error with go1.5 install

    Error with go1.5 install

    ~  gvm install go1.5                                                                                                                                
    Installing go1.5...
     * Compiling...
    ERROR: Failed to compile. Check the logs at /home/xxxxx/.gvm/logs/go-go1.5-compile.log
    ERROR: Failed to use installed version
    ~ cat /home/xxxxx/.gvm/logs/go-go1.5-compile.log                                                                                                   
    ##### Building Go bootstrap tool.
    cmd/dist
    ERROR: Cannot find /home/xxxxx/go1.4/bin/go.
    Set $GOROOT_BOOTSTRAP to a working Go tree >= Go 1.4.
    ./make.bash: line 121: /home/xxxxx/go1.4/bin/go: No such file or directory
    
  • gvm install go1.9.2 fails on macOS 10.12.6

    gvm install go1.9.2 fails on macOS 10.12.6

    I have already install go1.4 successed use: gvm install go1.4 -B when i install go1.9.2 got error:

    Downloading Go source... Installing go1.9.2...

    • Compiling... ERROR: Failed to compile. Check the logs at /Users/defned/.gvm/logs/go-go1.9.2-compile.log ERROR: Failed to use installed version

    cat /Users/defned/.gvm/logs/go-go1.9.2-compile.log

    Building Go bootstrap tool.

    cmd/dist

    Building Go toolchain using /Users/defned/.gvm/gos/go1.4.

    bootstrap/cmd/internal/dwarf bootstrap/cmd/internal/objabi bootstrap/cmd/internal/src bootstrap/cmd/internal/sys bootstrap/cmd/asm/internal/flags bootstrap/cmd/internal/bio bootstrap/math/bits bootstrap/cmd/compile/internal/syntax bootstrap/math/big bootstrap/cmd/internal/obj bootstrap/cmd/asm/internal/lex bootstrap/cmd/internal/gcprog bootstrap/debug/pe bootstrap/cmd/link/internal/ld bootstrap/cmd/internal/obj/arm bootstrap/cmd/internal/obj/arm64 bootstrap/cmd/internal/obj/mips bootstrap/cmd/internal/obj/ppc64 bootstrap/cmd/internal/obj/s390x bootstrap/cmd/internal/obj/x86 bootstrap/cmd/compile/internal/types bootstrap/cmd/asm/internal/arch bootstrap/cmd/compile/internal/ssa bootstrap/cmd/asm/internal/asm bootstrap/cmd/asm bootstrap/cmd/link/internal/amd64 bootstrap/cmd/link/internal/arm bootstrap/cmd/link/internal/arm64 bootstrap/cmd/link/internal/mips bootstrap/cmd/link/internal/mips64 bootstrap/cmd/link/internal/ppc64 bootstrap/cmd/link/internal/s390x bootstrap/cmd/link/internal/x86 bootstrap/cmd/link bootstrap/cmd/compile/internal/gc bootstrap/cmd/compile/internal/amd64 bootstrap/cmd/compile/internal/arm bootstrap/cmd/compile/internal/arm64 bootstrap/cmd/compile/internal/mips bootstrap/cmd/compile/internal/mips64 bootstrap/cmd/compile/internal/ppc64 bootstrap/cmd/compile/internal/s390x bootstrap/cmd/compile/internal/x86 bootstrap/cmd/compile

    Building go_bootstrap for host, darwin/amd64.

    runtime/internal/sys runtime/internal/atomic runtime encoding errors internal/cpu internal/race internal/syscall/windows/sysdll math/bits sync/atomic unicode unicode/utf16 unicode/utf8 math sync io internal/singleflight syscall cmd/go/internal/web hash bytes strings hash/adler32 bufio strconv path internal/syscall/windows internal/syscall/windows/registry time reflect encoding/base64 crypto crypto/sha1 internal/poll os os/signal sort encoding/binary fmt unexpected fault address 0x4cbfdb9a1a9 fatal error: fault [signal 0xb code=0x1 addr=0x4cbfdb9a1a9 pc=0xfda3f]

    goroutine 1 [running]: runtime.gothrow(0x70a230, 0x5) /usr/local/go/src/runtime/panic.go:503 +0x8e fp=0xc2083ff438 sp=0xc2083ff420 runtime.sigpanic() /usr/local/go/src/runtime/sigpanic_unix.go:29 +0x261 fp=0xc2083ff488 sp=0xc2083ff438 bootstrap/cmd/compile/internal/gc.livenessShouldTrack(0x4cbfdb9a12b, 0x7354b0) /Users/defned/.gvm/gos/go1.9.2/src/cmd/compile/internal/gc/plive.go:149 +0x1f fp=0xc2083ff4a0 sp=0xc2083ff488 bootstrap/cmd/compile/internal/gc.getvariables(0xc2083abe40, 0x0, 0x0, 0x0, 0x1) /Users/defned/.gvm/gos/go1.9.2/src/cmd/compile/internal/gc/plive.go:157 +0xd2 fp=0xc2083ff568 sp=0xc2083ff4a0 bootstrap/cmd/compile/internal/gc.liveness(0xc2085c8570, 0xc2085bd2c0, 0xc2085c8570) /Users/defned/.gvm/gos/go1.9.2/src/cmd/compile/internal/gc/plive.go:1287 +0x2b fp=0xc2083ff5d0 sp=0xc2083ff568 bootstrap/cmd/compile/internal/gc.genssa(0xc2085bd2c0, 0xc208588780) /Users/defned/.gvm/gos/go1.9.2/src/cmd/compile/internal/gc/ssa.go:4383 +0xb8 fp=0xc2083ff7f0 sp=0xc2083ff5d0 bootstrap/cmd/compile/internal/gc.compileSSA(0xc2083abe40, 0x0) /Users/defned/.gvm/gos/go1.9.2/src/cmd/compile/internal/gc/pgen.go:242 +0x85 fp=0xc2083ff880 sp=0xc2083ff7f0 bootstrap/cmd/compile/internal/gc.compile(0xc2083abe40) /Users/defned/.gvm/gos/go1.9.2/src/cmd/compile/internal/gc/pgen.go:219 +0x11a fp=0xc2083ff8f8 sp=0xc2083ff880 bootstrap/cmd/compile/internal/gc.funccompile(0xc2083abe40) /Users/defned/.gvm/gos/go1.9.2/src/cmd/compile/internal/gc/dcl.go:1049 +0x1a3 fp=0xc2083ff970 sp=0xc2083ff8f8 bootstrap/cmd/compile/internal/gc.Main(0x8275e8) /Users/defned/.gvm/gos/go1.9.2/src/cmd/compile/internal/gc/main.go:585 +0x30e9 fp=0xc2083ffee8 sp=0xc2083ff970 main.main() /Users/defned/.gvm/gos/go1.9.2/src/cmd/compile/main.go:49 +0x1c5 fp=0xc2083fff98 sp=0xc2083ffee8 runtime.main() /usr/local/go/src/runtime/proc.go:63 +0xf3 fp=0xc2083fffe0 sp=0xc2083fff98 runtime.goexit() /usr/local/go/src/runtime/asm_amd64.s:2232 +0x1 fp=0xc2083fffe8 sp=0xc2083fffe0 go tool dist: FAILED: /Users/defned/.gvm/gos/go1.9.2/pkg/tool/darwin_amd64/compile -pack -o /var/folders/h1/sdy0c6v907z7ylyw7650364w0000gp/T/go-tool-dist-513999791/sort/go.a -p sort /Users/defned/.gvm/gos/go1.9.2/src/sort/search.go /Users/defned/.gvm/gos/go1.9.2/src/sort/sort.go /Users/defned/.gvm/gos/go1.9.2/src/sort/zfuncversion.go: exit status 2 can't create /var/folders/h1/sdy0c6v907z7ylyw7650364w0000gp/T/go-tool-dist-513999791/encoding/binary/go.a: open /var/folders/h1/sdy0c6v907z7ylyw7650364w0000gp/T/go-tool-dist-513999791/encoding/binary/go.a: no such file or directory can't create /var/folders/h1/sdy0c6v907z7ylyw7650364w0000gp/T/go-tool-dist-513999791/fmt/go.a: open /var/folders/h1/sdy0c6v907z7ylyw7650364w0000gp/T/go-tool-dist-513999791/fmt/go.a: no such file or directory

    hope help me

  • Automatically `gvm use`... on per-directory .go-version files

    Automatically `gvm use`... on per-directory .go-version files

    chruby and ndenv help Ruby and Node.js programmers by automatically the right version of a programming language based on per-directory files like .ruby-version and .node-version. Could gvm do the same with .go-version files?

  • Conflict with GVM (Groovy enVironment Manager)

    Conflict with GVM (Groovy enVironment Manager)

    I had installed GVM (Groovy enVironment Manager) in my Ubuntu system.

    When I try to install gvm with

    bash < <(curl -s -S -L https://raw.githubusercontent.com/moovweb/gvm/master/binscripts/gvm-installer),

    I get ERROR: Already installed!.

    Is there anyway to install gvm without conflicting with GVM?

  • Use git repositories

    Use git repositories

    Golang has officially made the switch from Mercurial to git. GVM needs to be updated with respect to that, and mercurial needs to be removed from the requirements as a result.

  • Failed to install gb

    Failed to install gb

    Hey Guys,

    Sorry to bug you again, I don't know if it is a real issue or not, and it probably isn't a gvm issue, but when I try to install I get:

    ➜  ~  gvm install release.r60.3
    Downloading Go source...
    Installing release.r60.3...
     * Compiling...
     * Installing gb...
    Failed to install gb
     * Installing gpkg...
    

    Any and all help/advice is loved :)

    Thanks,

    Josh

  • gvm install fails on Ubuntu 12.04

    gvm install fails on Ubuntu 12.04

    After installing gvm (and it's prerequisites) and confirming that it works with gvm version: Go Version Manager v1.0.22 installed at /home/rihards/.gvm

    I get the following output when I try to run gvm install go1.4: Downloading Go source... Installing go1.4...

    • Compiling... ERROR: Failed to compile. Check the logs at /home/rihards/.gvm/logs/go-go1.4-compile.log ERROR: Failed to use installed version

    And the content of the said log file is:

    Building Go bootstrap tool.

    cmd/dist ERROR: Cannot find /home/rihards/go1.4/bin/go. Set $GOROOT_BOOTSTRAP to a working Go tree >= Go 1.4. ./make.bash: line 121: /home/rihards/go1.4/bin/go: No such file or directory

    This happens with other versions of go as well, and with different users on the system, including root. I've also tried removing .gvm and reinstalling it, still no luck.

  • .gvmrc Support

    .gvmrc Support

    This is a great project, and I can see myself using this to vendor my dependencies.

    Are there any plans or thoughts around adding .gvmrc support like .rvmrc from RVM? I am working on multiple Go projects at the moment, and auto switching between pkgsets when I switch directories would be fantastic.

    Thanks, -Phil

  • Issues on OSX

    Issues on OSX

    Hi! Cool project :+1:

    I notice you don't mention use on OSX, is it supported? If so, I'm having this issue:

    $ gvm install go1
    Installing go1...
     * Compiling...
    ERROR: Failed to compile
    ERROR: Failed to use installed version
    

    Is there a way to turn verbosity up so I can see the full stack trace and figure out what's going on?

  • odd error when running gvm command

    odd error when running gvm command

    Hey @moovweb,

    I installed gvm as per the instructions, and added the source line to my .zsh_profile but get the following error when I run the gvm command:

    ➜  ~  gvm
    gvm:20: = not found
    

    I am not sure how to diagnose this error, any help or advice would be greatly appreciated.

    Thanks a bundle,

    Josh

  • gvm install fails with

    gvm install fails with "go: command not found" on Ubuntu 18.04

    At 6ecd46d8b58c18f2a7bd5a1ab604cb57443cd35c:

    $ bash < <(curl -s -S -L https://raw.githubusercontent.com/moovweb/gvm/master/binscripts/gvm-installer)
    $ gvm install go1.11
    Downloading Go source...
    Installing go1.11...
     * Compiling...
    /home/ciro/.gvm/scripts/install: line 84: go: command not found
    ERROR: Failed to compile. Check the logs at /home/ciro/.gvm/logs/go-go1.11-compile.log
    ERROR: Failed to use installed version
    

    Installing Go with package manager solved it:

    sudo apt-get install golang-go
    

    but feels a bit bad to need go to install go. At least document the dep at: https://github.com/moovweb/gvm/tree/6ecd46d8b58c18f2a7bd5a1ab604cb57443cd35c#debianubuntu

  • Apple M1 Macbook Pro install:

    Apple M1 Macbook Pro install: "bad CPU type in executable: go"

    Following the installation instructions, in addition to thego1.5 section on the README:

    I am getting the following error when running anything with the binary installed go1.4, including go version or gvm install go1.5:

    zsh: bad CPU type in executable: go

    I have installed rosetta with softwareupdate --install-rosetta

    and which go points to the go1.4 version under GVM

    Any suggestions?

  • fix: 32 bit ARM

    fix: 32 bit ARM

    #372 will be fixed by this. This PR also allows s390x computers to use this. Mac's output arm64 when uname -m is run on the M1's, so support for that was added as well.

  • install gvm using zsh still update bashrc

    install gvm using zsh still update bashrc

    Here my zsh version is zsh 5.9 (x86_64-pc-linux-gnu), gvm version is v1.0.22. And I'm using oh-my-zsh. After install gvm, gvm updates my profile .bashrc, not .zshrc I use env | grep -i zsh, it prints

    SHELL=/usr/bin/zsh
    ZSH=/home/crimson/.oh-my-zsh
    

    It seems there is no ZSH_NAME environment variable, but ZSH Instead. It's ok for me to copy the code from bashrc to zshrc, but it would be better if got fixed. Here is a piece of code from gvm:

    if [ -z "$GVM_NO_UPDATE_PROFILE" ] ; then
      if [ -n "$ZSH_NAME" ]; then
        update_profile "$HOME/.zshrc"
      elif [ "$(uname)" == "Linux" ]; then
        update_profile "$HOME/.bashrc" || update_profile "$HOME/.bash_profile"
      elif [ "$(uname)" == "Darwin" ]; then
        update_profile "$HOME/.profile" || update_profile "$HOME/.bash_profile"
      fi
    fi
    
    
  • Allow referencing versions without the 'go' prefix

    Allow referencing versions without the 'go' prefix

    gvm install 1.19 should be synonymous with gvm install go1.19. Right now, it throws a ERROR: Unrecognized Go version. Would be a helpful quality of life fix. Having to supply the prefix go is pretty redundant..

A tool to determine the highest version number that's smaller than a target version number

semver-highest A tool to determine the highest version number that's smaller than a target version number. Installation go install github.com/marten-s

Oct 13, 2021
Go Version Manager

gvm By Josh Bussdieker (jbuss, jaja, jbussdieker) while working at Moovweb Currently lovingly maintained by Benjamin Knigge Pull requests and other an

Jan 9, 2023
Go Version Manager

gvm By Josh Bussdieker (jbuss, jaja, jbussdieker) while working at Moovweb Currently lovingly maintained by Benjamin Knigge Pull requests and other an

Jan 2, 2023
Golang Version Manager

g 注意:master分支可能处于开发之中并非稳定版本,请通过tag下载稳定版本的源代码,或通过release下载已编译的二进制可执行文件。 g是一个Linux、macOS、Windows下的命令行工具,可以提供一个便捷的多版本go环境的管理和切换。 特性 支持列出可供安装的go版本号 支持列出已安

Dec 30, 2022
Go version manager. Super simple tool to install and manage Go versions. Install go without root. Gobrew doesn't require shell rehash.

gobrew Go version manager Install or update With curl $ curl -sLk https://git.io/gobrew | sh - or with go $ go get -u github.com/kevincobain2000/gobre

Jan 5, 2023
Declarative CLI Version manager. Support Lazy Install and Sharable configuration mechanism named Registry. Switch versions seamlessly

aqua Declarative CLI Version manager. Support Lazy Install and Sharable configuration mechanism named Registry. Switch versions seamlessly. Index Slid

Dec 29, 2022
Dontfile-simple - The simplest version of an online file manager

dontfile-simple The simplest version of an online file manager. Built With Golan

Jan 12, 2022
Golangver - Go's distributives version manager

golangver Go's distributive version manager (knitted myself with love :) Require

Sep 20, 2022
Go Package Manager (gopm) is a package manager and build tool for Go.

?? ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? In favor of Go Modules Proxy since Go 1.11, this pr

Dec 14, 2022
painless task queue manager for shell commands with an intuitive cli interface (execute shell commands in distributed cloud-native queue manager).

EXEQ DOCS STILL IN PROGRESS. Execute shell commands in queues via cli or http interface. Features Simple intuitive tiny cli app. Modular queue backend

Dec 14, 2022
Terraform Provider for Azure (Resource Manager)Terraform Provider for Azure (Resource Manager)
Terraform Provider for Azure (Resource Manager)Terraform Provider for Azure (Resource Manager)

Terraform Provider for Azure (Resource Manager) Version 2.x of the AzureRM Provider requires Terraform 0.12.x and later, but 1.0 is recommended. Terra

Oct 16, 2021
A node.js version management utility for Windows. Ironically written in Go.
A node.js version management utility for Windows. Ironically written in Go.

The npm/Microsoft/Google recommended Node.js version manager for Windows. This is not the same thing as nvm. The original nvm is a completely separate

Jan 2, 2023
The pure golang implementation of nanomsg (version 1, frozen)
The pure golang implementation of nanomsg (version 1, frozen)

mangos NOTE: This is the legacy version of mangos (v1). Users are encouraged to use mangos v2 instead if possible. No further development is taking pl

Dec 7, 2022
libsvm go version

libsvm golang version libsvm golang version derived work based on LIBSVM 3.14. Info this lib based on LIBSVM java version, just translate java to go.

Sep 27, 2022
A Go interface to ZeroMQ version 4

A Go interface to ZeroMQ version 4. Warning Starting with Go 1.14, on Unix-like systems, you will get a lot of interrupted signal calls. See the top o

Dec 25, 2022
This is a Golang wrapper for working with TMDb API. It aims to support version 3.
This is a Golang wrapper for working with TMDb API. It aims to support version 3.

This is a Golang wrapper for working with TMDb API. It aims to support version 3. An API Key is required. To register for one, head over to themoviedb

Dec 27, 2022
"go build" wrapper to add version info to Golang applications

govvv The simple Go binary versioning tool that wraps the go build command. Stop worrying about -ldflags and go get github.com/ahmetb/govvv now. Build

Dec 16, 2022
A live-updating version of the UNIX wc command.
A live-updating version of the UNIX wc command.

lwc A live-updating version of the UNIX wc command. Installation You can get a prebuilt binary for every major platform from the Releases page. Just e

Jul 26, 2022
A Go interface to ZeroMQ version 2

A Go interface to ZeroMQ version 2. Requires ZeroMQ version 2.1 or 2.2 For ZeroMQ version 4, see: http://github.com/pebbe/zmq4 For ZeroMQ version 3, s

May 26, 2021
A Go interface to ZeroMQ version 3

A Go interface to ZeroMQ version 3. For ZeroMQ version 4, see: http://github.com/pebbe/zmq4 For ZeroMQ version 2, see: http://github.com/pebbe/zmq2 In

Sep 24, 2022