LoginSignup
0
0

More than 5 years have passed since last update.

Mac で go を使う

Posted at

brew でインストール。
バイナリパッケージなら cask を使います。

$ brew cask install go

ホームフォルダの .bashrc を編集。

テキストエディットなどのエディタで編集するのですが、通常は不可視ファイルなのでファイルダイアログで command + shift + . を押して .bashrc を表示させます。

.bashrc に次の内容を追記。

$HOME/.bashrc
export GOPATH="${HOME}/.go"
export GOROOT="$(brew --prefix)/go"
export PATH="$PATH:${GOPATH}/bin:${GOROOT}/bin"

test -d "${GOPATH}" || mkdir "${GOPATH}"
test -d "${GOPATH}/src/github.com" || mkdir -p "${GOPATH}/src/github.com"

ファイルを保存したら、保存した直後だけは

$ . ~/.bashrc

を実行。普段はターミナルを開けば自動で設定は読み込まれます。

$ go version
go version go1.6.2 darwin/amd64

go のバージョンを表示させてみて動作を確認。

出典:Install go with brew, and running the gotour

※GOROOT の PATH が環境によって違うかも。出典では /usr/local/Celler/go/libexec ($(brew --prefix golang)/libexec) となっていたけど自分の環境では /usr/local/go みたいなので。

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