2
0

More than 1 year has passed since last update.

Golangのデバッガdelveで「error layer=debugger can't find build-id note on binary」と表示されたときの対処法

Last updated at Posted at 2022-02-13

問題

表題の通り、以下のエラーによりVSCodeでGolangのデバッグ実行に失敗するという問題に直面しました。

2022-02-12T08:26:42+09:00 error layer=debugger can't find build-id note on binary
panic: runtime error: slice bounds out of range [:2] with length 0
---(省略)

解決

go-delve/delveのissueによると
@latestでインストールされるdelve@1.8.2(2022/02/13時点)ではこの問題に対処されていないため
VSCodeの拡張機能などによるインストールではなく手動でdelveをインストールします。

# Install at tree head:
$ go install github.com/go-delve/delve/cmd/dlv@master

もし、以下のエラーによりインストールに失敗する場合は、

go: github.com/go-delve/delve/cmd/dlv@master (in github.com/go-delve/delve@v1.8.2-0.20220210175055-dee4437bd088):
    The go.mod file for the module providing named packages contains one or
    more replace directives. It must not contain directives that would cause
    it to be interpreted differently than if it were the main module.

次のコマンドを実行してください。

$ git clone https://github.com/go-delve/delve
$ cd delve
$ go install github.com/go-delve/delve/cmd/dlv

delve@v1.8.2のインストールが完了後、ブレークポイントを設定してデバッグ実行します。

image.png

参考文献

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