Meng小羽

Debug客栈

永远相信美好的事情即将发生! 非标准程序猿 / 🧑‍💻爱编码 / 📹爱摄影 / ⛰️爱徒步 / ❤️更爱女朋友 / 米家好物推荐官 关注我哦,让我们一起变得更强~
github
x
bilibili
zhihu
youtube
follow
email

Using GVM tool to manage Go versions

In Go project development, teams need to maintain consistent development versions. How can they quickly install, deploy, and switch Go environments? Here, I recommend a tool called GVM (Go Version Manager). It can conveniently switch and customize Go Path, Go Root, and other parameters. It is a practical tool for installing and managing multiple versions.

GVM, similar to RVM in Ruby (https://rvm.io/), and jenv in Java (https://github.com/linux-china/jenv) (domestic), can be used to easily manage Go versions. It has the following main features:

  • Manage multiple versions of Go, including installation, uninstallation, and specifying the use of a certain version of Go;
  • View all available official Go versions, as well as the locally installed and default versions being used;
  • Manage multiple GOPATHs and edit Go environment variables;
  • Associate the current directory with GOPATH;
  • View file differences under GOROOT.

Installing#

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

Alternatively, if you are using zsh, simply change bash to zsh.

Using GVM#

You can use gvm to view supported operations:

  ~ gvm     
Usage: gvm [command]

Description:
  GVM is the Go Version Manager

Commands:
  version    - print the gvm version number
  get        - gets the latest code (for debugging)
  use        - select a go version to use (--default to set permanently)
  diff       - view changes to Go root
  help       - display this usage text
  implode    - completely remove gvm
  install    - install go versions
  uninstall  - uninstall go versions
  cross      - install go cross compilers
  linkthis   - link this directory into GOPATH
  list       - list installed go versions
  listall    - list available versions
  alias      - manage go version aliases
  pkgset     - manage go packages sets
  pkgenv     - edit the environment for a package set

Installing Go Versions#

For example, to install go1.13 version:

gvm install go1.13

Viewing Go Versions#

  ~ gvm list          

gvm gos (installed)

   go1.12
=> system

Switching Go Versions#

gvm use go1.**

Managing Gopath Environment#

GVM provides a simple tool called gvm pkgset to create and use GOPATH environments:

  ~ gvm pkgset
= gvm pkgset

* http://github.com/moovweb/gvm
== DESCRIPTION:
GVM pkgset is used to manage various Go packages
== Usage
  gvm pkgset Command

== Command
  create     - create a new package set
  delete     - delete a package set
  use        - select where gb and goinstall target and link
  empty      - remove all code and compiled binaries from package set
  list       - list installed go packages

Uninstalling#

To uninstall a installed Go version:

gvm uninstall go1.13

Open Source Code#

GVM is a convenient tool implemented using Shell scripts. As an open-source project, I recommend everyone to give it a Star support.

Loading...
Ownership of this post data is guaranteed by blockchain and smart contracts to the creator alone.