LoginSignup
6
6

More than 5 years have passed since last update.

GoをOSXにインストールする

Posted at

GoをOSXにインストール

Goのダウンロードページからインストーラーをダウンロードします。

僕の環境はOS 10.8以上の64bitなので、go1.3.3.darwin-amd64-osx10.8.pkgをダウンロードしました。

ダウンロードしたインストーラーを実行して、手順にしたがってインストールを進めていきます。

インストールが完了すると、/usr/local/go ディレクトリ以下にgoのtoolが設置されています。

$ ls /usr/local/go
AUTHORS      LICENSE      README       api          blog         favicon.ico  lib          pkg          src
CONTRIBUTORS PATENTS      VERSION      bin          doc          include      misc         robots.txt   test

PATHにGOを追加する

go コマンドを実行出来るようにPATHに /usr/local/go/bin を追加します。

僕はzshを使っているので、~/.zshrcに以下のように記述しました。

export PATH="/usr/local/go/bin:$PATH"

shellで以下のコマンドを実行できればインストール成功です。

$ go version
go version go1.3.3 darwin/amd64

GoでHelloWorld

hello.goに以下のように記述します。

hello.go
package main

import "fmt"

func main(){
     fmt.Printf("hello, world\n")
}

そして以下のようにコマンドで実行します。

$ go run hello.go
hello, world

参考URL
https://golang.org/doc/install

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