ソースコードから理解する技術-UnderSourceCode

手を動かす(プログラムを組む)ことで技術を理解するブログ

Visual Studio CodeでGo言語(golang)のユニットテストをデバッグする

タイトルにあるように、Visual Studio CodeGolangユニットテストを実行してデバッグする方法についてです。
とは言っても、ほとんどデバッグ時の設定手順と同じですが・・・。

デバッグ時の設定手順

  1. メニューバーの「Debug」より「Open Configurations」か「Add Configurations」を選ぶ。
  2. launch.jsonが開く。
  3. 「mode」の値を「test」に変更して保存する。
{
    // Use IntelliSense to learn about possible attributes.
    // Hover to view descriptions of existing attributes.
    // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
    "version": "0.2.0",
    "configurations": [
        {
            "name": "Launch",
            "type": "go",
            "request": "launch",
            "mode": "test",
  1. F5を押し、デバッグを実行する。

以上です。