2
3

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

Dockerの中のGolangプログラムをIntelliJでデバッグする

Last updated at Posted at 2018-03-19
  • Dockerコンテナ(イメージ)にdelveをインストールしておく
  • IntelliJでGo RemoteのRun configurationを作る。ここでデバッガの通信に使うportを設定する(ここではデフォルトの2345だとする)
  • 以下のオプションでコンテナを立ち上げる
    • -p 2345:2345
    • --security-opt seccomp=unconfinedオプションをつける
  • 対象のプログラムがhello.goだとして、↑のコンテナで以下のコマンドを実行する
    • dlv debug --headless --listen=:2345 --api-version=2 hello.go
  • IntelliJで作ったRun configurationをDebug実行する。

サンプルプロジェクト作った。↓をcloneしてdocker-compose upしてIntelliJのGo Remoteのデフォルト設定を実行したらデバッグできる。

2
3
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
2
3

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?