[Gvm] Go version control

Introduction

Version matching needs to be matched in collective development, and version control is a must. This article keeps a record of version control in Go.

Go version control tool [gvm]

Handles Go version manager (hereinafter gvm) https://github.com/moovweb/gvm

How to use gvm

There are three main steps to use gvm:

  1. Install gvm
  2. Install the go version
  3. Use a specific version of go

1. gvm installation

To install gvm, do the following on your terminal

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

Check if the installation is running correctly

$ gvm version
Go Version Manager v1.0.22 installed at hoge

2. Install the go version

After confirming the installation of gvm, import the version of go handled in development.

gvm install go1.15.6

At this time, the following error may occur.

gvm install go1.15.6
Installing go1.15.6...
 * Compiling...
ERROR: Failed to compile. Check the logs at /Users/ko-wa/.gvm/logs/go-go1.15.6-compile.log
ERROR: Failed to use installed version

If you get this error, install the binary as a workaround.

$ gvm install go1.15.6 -B
Installing go1.15.6 from binary source

Reference: https://akataworks.hatenadiary.jp/entry/2016/10/18/201025

3. Use a specific version of go

Switch the installed version again using the gvm command.

$ gvm use go1.15.6
Now using version go1.15.6

Check the version of go.

$ go version
go version go1.15.6 darwin/amd64

It's okay if it's the default version!

Always make gvm available

gvm will not be available if you reopen the terminal, so you need to set bash_profile (which runs first when the terminal is opened)

$ cat $HOME/.gvm/scripts/gvm >> ~/.bash_profile

If written, gvm is always available.

Change Go version defaults

Finally, I will write how to change the default if you want to fix the version of Go.

$ gvm use go1.15.6 --default
Now using version go1.15.6

This is how to use Go version control and gvm.

Recommended Posts

[Gvm] Go version control
About Go control syntax
Perform multiple version control of Go with anyenv + goenv
Virtual Environment Version Control Summary Python
SciPy version does not go up (Mac)