I had to use GO, so I created an environment with Mac OS Big Sur.
--Installing goenv --go installation
Initially, I would like to install with brew install goenv
,
I installed it with Git because the version was old.
% git clone https://github.com/syndbg/goenv.git ~/.goenv
Since the shell uses zsh, we set environment variables.
% echo 'export GOENV_ROOT="$HOME/.goenv"' >> ~/.zshrc
% echo 'export PATH="$GOENV_ROOT/bin:$PATH"' >> ~/.zshrc
% echo 'eval "$(goenv init -)"' >> ~/.zshrc
Restart the shell for the environment variables to take effect.
% exec $SHELL
Check the version of goenv.
% goenv -v
goenv 2.0.0beta11
Check the version of go that can be installed.
% goenv install -l
Available versions:
1.2.2
1.3.0
:
1.15.4
1.15.5
1.15.6
1.16beta1
Install go by specifying the version.
% goenv install 1.15.6
Since the shell uses zsh, we set environment variables.
% echo 'export PATH="$GOROOT/bin/$PATH"' >> ~/.zshrc
% echo 'export PATH="$PATH:$GOPATH/bin"' >> ~/.zshrc
% exec $SHELL
At this point, the following settings should have been added to ~/.zshrc
.
export GOENV_ROOT="$HOME/.goenv"
export PATH="$GOENV_ROOT/bin:$PATH"
eval "$(goenv init -)"
export PATH="$GOROOT/bin/$PATH"
export PATH="$PATH:$GOPATH/bin"
Specify the version of GO to use.
% goenv global 1.15.6
Check the GO version.
% go version
go version go1.15.6 darwin/amd64
I want to specify the location of the project arbitrarily, so set Go Modules. First, check the Go Modules settings.
% go env GO111MODULE
If it is set, on
will be displayed, but it will not be displayed, so set it.
% go env -w GO111MODULE=on
% go env GO111MODULE
on
Now that the GO environment has been created,
Let's proceed with go mod init <project name>
.
Recommended Posts