LoginSignup
0
1

More than 1 year has passed since last update.

Mac初心者のGoインストール

Last updated at Posted at 2021-05-14

Goを使ってみたいと思ったのだ。

環境

  • MacBook Air (M1, 2020)
  • macOS Big Sur 11.3.1
  • zsh

制約

M1 Macがネイティブサポートされた、go version 1.6以降を入れたい

goenvのインストール

Homebrewでインストールしたら最新のGoはサポートされていないようだったので、公式のgitからインストールする。

基本は公式のインストール手順に従う。

goenvのclone

% git clone https://github.com/syndbg/goenv.git ~/.goenv

環境変数の設定

% echo 'export GOENV_ROOT="$HOME/.goenv"' >> ~/.zshrc
% echo 'export PATH="$GOENV_ROOT/bin:$PATH"' >> ~/.zshrc
% echo 'eval "$(goenv init -)"' >> ~/.zshrc
% echo 'export PATH="$GOROOT/bin:$PATH"' >> ~/.zshrc
% echo 'export PATH="$PATH:$GOPATH/bin"' >> ~/.zshrc

シェルを立ち上げ直して環境変数を適用する

% exec $SHELL

goのインストール

% goenv install --list
% goenv install 1.16.3
% goenv global 1.16.3
% goenv rehash
% go version  
go version go1.16.3 darwin/arm64

備忘録

goenvをupgradeするときはgit pullする

$ cd ~/.goenv
$ git pull
0
1
1

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
1