LoginSignup
1
1

More than 5 years have passed since last update.

IntelliJでGoの開発環境を整える

Posted at

環境

OS: macOS High Sierra
shell: fish

インストールするもの

  • go
  • delve
  • IntelliJ Go plugin

Goのインストール

homebrewでインストール。

$ brew install go

GOPATHを設定。

~/.config/fish/config.fish
# GOPATH
set -x GOPATH $HOME/go
set -x PATH $GOPATH/bin $PATH

delveのインストール

derekparker/delveはGo言語用のデバッガ。

コマンドラインツールをインストール。

$ xcode-select --install 

delveのインストール。

こちらによると、
goとdelveを共にhomebrewでインストールするとエラーが発生する場合があるので、マニュアルインストールします。

$ go get -u github.com/derekparker/delve 
$ cd $GOPATH/src/github.com/derekparker/delve
$ make install

IntelliJにGoプラグインをインストール

Goのプラグインを追加。

intellij.png

デバッグしてみる

New ProjectでGoプロジェクトを作成。

スクリーンショット 2017-11-10 10.05.22.png

hello.goを準備してブレークポイントを置く。
スクリーンショット 2017-11-10 9.59.45.png

デバッグ開始。
スクリーンショット 2017-11-10 9.59.27.png

ちゃんとブレークポイントで処理が止まる!
スクリーンショット 2017-11-10 10.01.50.png

参照

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