Mac OS X 10.14.2 へ Homebrew で Go 言語をインストールする

Mac OS X 10.14.2 へ Go 言語を Homebrew でインストールする手順をメモしておきます。 といっても、従来の手順と同じです。

Homebrew でインストールされるバージョン

現時点 (2018/12/14) でインストールされるのは 1.11.3 のようでした。

$ brew info go
go: stable 1.11.3 (bottled), HEAD
Open source programming language to build simple/reliable/efficient software
The Go Programming Language
Go is an open source programming language that makes it simple to build secure, scalable systems.
/usr/local/Cellar/go/1.11.3 (9,287 files, 404.1MB) * Poured from bottle on 2018-12-14 at 15:15:28 From: https://github.com/Homebrew/homebrew-core/blob/master/Formula/go.rb ==> Requirements Required: macOS >= 10.10 ✔ ==> Options --HEAD Install HEAD version ==> Caveats A valid GOPATH is required to use the `go get` command. If $GOPATH is not specified, $HOME/go will be used by default: https://golang.org/doc/code.html#GOPATH You may wish to add the GOROOT-based install location to your PATH: export PATH=$PATH:/usr/local/opt/go/libexec/bin ==> Analytics install: 64,548 (30 days), 246,405 (90 days), 958,670 (365 days) install_on_request: 45,902 (30 days), 174,848 (90 days), 617,630 (365 days) build_error: 0 (30 days)

インストール

Homebrew でインストールするだけです。

brew install go

インストール後の設定

環境変数を定義しておきます。 今回はログインシェルに bash を使っているので、~/.bash_profile に以下を追記しました。

export GOROOT=/usr/local/opt/go/libexec
export GOPATH=$HOME
export PATH=$PATH:$GOROOT/bin:$GOPATH/bin

コメント

タイトルとURLをコピーしました