2
2

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

Macにgoをインストールするまで

Posted at

macにgoをインストールするまで

インストール手順

anyenvのインストール

brew install anyenv
# .bash_profileを直接変更しても良い
echo 'eval "$(anyenv init -)"' >> ~/.bash_profile
exec $SHELL -l

goenvのインストール

anyenv install goenv
# インストールができてるか確認できる
goenv -v

exec $SHELL -l
goenv install -l
# 何もなければ最新のバージョンをインストール
goenv install 1.12.1
# 特定ディレクトリ配下で異なるバージョン使いたければlocal使う
goenv global 1.12.1

# インストールできてるか確認
go version

GOPATHの追加

hadaは$HOME直下にgoディレクトリを作成してそこをGOPATHにした

最終的な.bash_profile

.bash_profile
export GOPATH=$HOME/go
export GOBIN=$GOPATH/1.12.1/bin
export PATH=$GOPATH/bin:$PATH
eval "$(anyenv init -)"

go envとかでgo周りの環境変数が正しく設定されてるか確認
GOPATHにバージョン名のディレクトリとかできるけど気にしない
/Users/yota.hada/go/1.12.1

depを入れる

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

# GOBINを設定してればdepコマンドが使えるはず
dep version

vscode使ってる場合

goの拡張機能入れる

settingにGOPATHを追加する

settings.json
"go.gocodeAutoBuild": true,
"go.gopath": "/Users/yota.hada/go/1.12.1",

最初にgoファイル開いたときに推奨のライブラリとかおすすめされるのでインストールしておく

2
2
0

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
2
2

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?