Install Go with goenv at macOS

This is a note on how to install goenv on macOS and how to use it.

1. Install goenv

Install goenv.

1
$ git clone https://github.com/syndbg/goenv.git ~/.goenv

Add the following to .bash_profile

1
2
3
4
# goenv
export GOENV_ROOT="$HOME/.goenv"
export PATH="$GOENV_ROOT/bin:$PATH"
eval "$(goenv init -)"

Load .bash_profile in shell

1
$ source .bash_profile

2. How to Use goenv ( Install and manage Go )

How to check which version you can use

1
$ goenv install -l

How to check which version you insatlled

1
$ goenv versions

How to install the specified version of Go

1
$ goenv install 1.10.3

Run this command after you install a new version of Go

1
$ goenv rehash

How to use the specified version of Go at global

1
$ goenv global 1.10.3

How to use the specified version of Go at local ( directory ).

1
$ goenv local 1.10.3

This command will create .go-version file at current directory.

3. How to use dep

dep is package manager of golang.

1
$ go get -u github.com/golang/dep/cmd/dep

4. How to Update goenv

1
2
$ cd $(goenv root)
$ git pull