LoginSignup
7
6

More than 5 years have passed since last update.

Goの開発環境構築

Posted at

環境

Mac High Serrie 10.13.3
fish

手順1:Goのインストール

$ brew install go

GoのインストールパスのことをGOROOTという。
GOROOTは
$ go env GOROOT
で取得できる。

手順2:$PATHを通す

コマンドを実行するときにフルパスを入れずに済むように$PATHを通す。
bash、zeshとかだと設定ファイル(zeshrcとか)に以下を追加すればいい。

export GOPATH=$HOME/dev(←ワークスペースにしたい場所)
export PATH=$PATH:$GOPATH/bin

fishを使っている場合は~/.config/fish/config.fishに以下を追加する。

set -x GOPATH $HOME/dev
set -x PATH $PATH $GOPATH/bin

ここまででgoの開発環境構築は完了。
ここから先はもっと便利にする観点。

手順3:goreをインストール

goreはGoの代表的なREPL。対話的にプログラムを実行し、評価を出力することができる。
$ go get github.com/motemen/gore
goreがインストールされているか確認するために実行してみる。

$gore autoimport
gore version 0.3.0  :help for help
gore> fmt.Println("Hello world")
Hello world
12
<nil>
gore>

goreを終了するためにはCtrl + d

他の便利なパッケージ

  • gocode (github.com/nsf/gocode)
  • pp (github.com/k0kubun/pp)
  • godoc (golang.org/x/tools/cmd/godoc)
7
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
7
6