LoginSignup
5
1

More than 5 years have passed since last update.

Go TourをMacのローカルで実行

Last updated at Posted at 2016-04-02

[目的]
Go言語の学習ができる、A Tour of Go をローカルで実行できるようにする。

GOPATHの確認

GOPATHが設定されているか確認
echo $GOPATH
/Users/user1/go

もし設定されていなければ、適当なパスをGOPATHに指定

.bash_profile等に追記
export GOPATH=$HOME/go
反映
source ~/.bash_profile

Go Tourのインストール

Xcode licenseの同意をしていないと以下のようになる。

sudo go get golang.org/x/tour/gotour
cd .; git clone https://go.googlesource.com/tour /Users/user1/go/src/golang.org/x/tour

You have not agreed to the Xcode license agreements, please run 'xcodebuild -license' (for user-level acceptance) or 'sudo xcodebuild -license' (for system-wide acceptance) from within a Terminal window to review and agree to the Xcode license agreements.
package golang.org/x/tour/gotour: exit status 69

その場合、まずはXcode licenseに同意する。

sudo xcodebuild -license
You have not agreed to the Xcode license agreements. You must agree to both license agreements below in order to use Xcode.

Hit the Enter key to view the license agreements at '/Applications/Xcode.app/Contents/Resources/English.lproj/License.rtf'

Apple Inc.

Xcode and Apple SDKs Agreement

PLEASE SCROLL DOWN AND READ ALL OF THE FOLLOWING TERMS AND CONDITIONS CAREFULLY BEFORE USING THE APPLE SOFTWARE OR APPLE SERVICES.  THIS IS A LEGAL AGREEMENT BETWEEN YOU AND APPLE.  【略】
By typing 'agree' you are agreeing to the terms of the software license agreements. Type 'print' to print them or anything else to cancel, [agree, print, cancel]
agree
You can view the license agreements in Xcode's About Box, or at /Applications/Xcode.app/Contents/Resources/English.lproj/License.rtf

Go Tourをインストールする。

sudo go get golang.org/x/tour/gotour

Go Tourをローカルで実行

cd $GOPATH/bin
./gotour
2016/04/02 15:30:00 Serving content from /Users/user1/go/src/golang.org/x/tour
2016/04/02 15:30:00 A browser window should open. If not, please visit http://127.0.0.1:3999
2016/04/02 15:30:01 accepting connection from: 127.0.0.1:61753

ブラウザが立ち上がり、http://127.0.0.1:3999 でGo Tourが実行できる。

5
1
2

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
5
1