title: Why does debugging Go with VS Code and WSL hang Delve?
body: <p>I am trying to debug a Go program in VS Code, using WSL.  The program compiles and runs, but when trying to debug with dlv dap, it seems to hang and never reach the first breakpoint.  I am using go 1.17, dlv 1.7.2 and Ubuntu  20.04.  The problem is replicated with the simple Hello World program:</p>
  <pre><code>package main
  
  import &quot;fmt&quot;
  
  func main() {
      fmt.Println(&quot;hello world&quot;)
  }
  </code></pre>
  <p>If I chose Run-&gt;Run Without Debugging, the Debug Consol shows</p>
  <blockquote>
  <p>Starting: /mnt/f/mattm/home/go/bin/dlv-dap dap
  --check-go-version=false --only-same-user=false --listen=127.0.0.1:53252 --log=true --log-output=rpc --log-dest=3 from /mnt/f/mattm/home/hw <br>DAP server listening at: 127.0.0.1:53252 <br>
  hello world <br>
  Process 17851 has exited with status 0 dlv dap (17754) exited with code: 0</p>
  </blockquote>
  <p>The program has run and exited successfully (though why start dlv if not debugging?)  But if I try to Run-&gt;Start Debugging, the console window only shows:</p>
  <blockquote>
  <p>Starting: /mnt/f/mattm/home/go/bin/dlv-dap dap
  --check-go-version=false --only-same-user=false --listen=127.0.0.1:56084 --log=true --log-output=rpc --log-dest=3 from /mnt/f/mattm/home/hw <br> DAP server listening at: 127.0.0.1:56084</p>
  </blockquote>
  <p>The program does not appear to execute, VS Code never shows execution reaching a breakpoint. (The outcome is the same whether or not I've set breakpoints).  Task Manager does show a dlv-dap process running; it appears to be hung and waiting for something.  But what?  If I terminate debugging under VS Code, the dlv-dap process remains.  It is as though VS Code spun off the dlv process and then forgotten about it.  Do I need to prompt VS Code to connect to the DAP server to proceed?  How do I do that?</p>
  <p><strong>Addendum:</strong>
  I am using the following launch configuration:</p>
  <pre><code>&quot;name&quot;: &quot;Launch Package&quot;,
  &quot;type&quot;: &quot;go&quot;,
  &quot;request&quot;: &quot;launch&quot;,
  &quot;mode&quot;: &quot;debug&quot;,
  &quot;program&quot;: &quot;${fileDirname}&quot;,
  &quot;logOutput&quot;: &quot;dap,debugger&quot;,
  &quot;showLog&quot;: true,
  &quot;dlvFlags&quot; : [&quot;--only-same-user=false&quot;]
  </code></pre>
  <p>After turning on verbose dlv logging (as in the config above), I get the following:</p>
  <blockquote>
  <p>Starting: /mnt/f/mattm/home/go/bin/dlv-dap dap
  --check-go-version=false --only-same-user=false --listen=127.0.0.1:51444 --log=true --log-output=dap,debugger --log-dest=3 from /mnt/f/mattm/home/breezepms/hello-world DAP server listening at: 127.0.0.1:51444 2021-10-17T16:35:27+01:00 debug
  layer=dap DAP server pid = 7019 2021-10-17T16:35:27+01:00 debug
  layer=dap DAP connection started 2021-10-17T16:35:27+01:00 debug
  layer=dap [&lt;- from
  client]{&quot;seq&quot;:1,&quot;type&quot;:&quot;request&quot;,&quot;command&quot;:&quot;initialize&quot;,&quot;arguments&quot;:{&quot;clientID&quot;:&quot;vscode&quot;,&quot;clientName&quot;:&quot;Visual
  Studio
  Code&quot;,&quot;adapterID&quot;:&quot;go&quot;,&quot;locale&quot;:&quot;en-gb&quot;,&quot;linesStartAt1&quot;:true,&quot;columnsStartAt1&quot;:true,&quot;pathFormat&quot;:&quot;path&quot;,&quot;supportsVariableType&quot;:true,&quot;supportsVariablePaging&quot;:true,&quot;supportsRunInTerminalRequest&quot;:true,&quot;supportsMemoryReferences&quot;:true,&quot;supportsProgressReporting&quot;:true,&quot;supportsInvalidatedEvent&quot;:true}}
  2021-10-17T16:35:27+01:00 debug layer=dap [-&gt; to
  client]{&quot;seq&quot;:0,&quot;type&quot;:&quot;response&quot;,&quot;request_seq&quot;:1,&quot;success&quot;:true,&quot;command&quot;:&quot;initialize&quot;,&quot;body&quot;:{&quot;supportsConfigurationDoneRequest&quot;:true,&quot;supportsFunctionBreakpoints&quot;:true,&quot;supportsConditionalBreakpoints&quot;:true,&quot;supportsEvaluateForHovers&quot;:true,&quot;supportsSetVariable&quot;:true,&quot;supportsExceptionInfoRequest&quot;:true,&quot;supportTerminateDebuggee&quot;:true,&quot;supportsDelayedStackTraceLoading&quot;:true,&quot;supportsLogPoints&quot;:true,&quot;supportsClipboardContext&quot;:true,&quot;supportsSteppingGranularity&quot;:true}}
  2021-10-17T16:35:27+01:00 debug layer=dap [&lt;- from
  client]{&quot;seq&quot;:2,&quot;type&quot;:&quot;request&quot;,&quot;command&quot;:&quot;launch&quot;,&quot;arguments&quot;:{&quot;name&quot;:&quot;Launch
  file&quot;,&quot;type&quot;:&quot;go&quot;,&quot;request&quot;:&quot;launch&quot;,&quot;mode&quot;:&quot;debug&quot;,&quot;program&quot;:&quot;./hello-world.go&quot;,&quot;logOutput&quot;:&quot;dap,debugger&quot;,&quot;showLog&quot;:true,&quot;dlvFlags&quot;:[&quot;--only-same-user=false&quot;],&quot;__configurationTarget&quot;:5,&quot;packagePathToGoModPathMap&quot;:{&quot;/mnt/f/mattm/home/breezepms/web/xmlutilities&quot;:&quot;/mnt/f/mattm/home/breezepms/web/xmlutilities&quot;,&quot;/mnt/f/mattm/home/breezepms/ledgers&quot;:&quot;/mnt/f/mattm/home/breezepms/ledgers&quot;,&quot;/mnt/f/mattm/home/breezepms/web&quot;:&quot;/mnt/f/mattm/home/breezepms&quot;,&quot;/mnt/f/mattm/home/breezepms/web/filehandling&quot;:&quot;/mnt/f/mattm/home/breezepms/web/filehandling&quot;,&quot;/mnt/f/mattm/home/breezepms/persistence&quot;:&quot;/mnt/f/mattm/home/breezepms/persistence&quot;,&quot;/mnt/f/mattm/home/breezepms/cmd/csvloader&quot;:&quot;/mnt/f/mattm/home/breezepms&quot;,&quot;/mnt/f/mattm/home/breezepms/hello-world&quot;:&quot;/mnt/f/mattm/home/breezepms&quot;},&quot;debugAdapter&quot;:&quot;dlv-dap&quot;,&quot;apiVersion&quot;:2,&quot;dlvLoadConfig&quot;:{&quot;followPointers&quot;:true,&quot;maxVariableRecurse&quot;:1,&quot;maxStringLen&quot;:64,&quot;maxArrayValues&quot;:64,&quot;maxStructFields&quot;:-1},&quot;showGlobalVariables&quot;:false,&quot;substitutePath&quot;:[],&quot;dlvToolPath&quot;:&quot;/mnt/f/mattm/home/go/bin/dlv-dap&quot;,&quot;env&quot;:{},&quot;__buildDir&quot;:&quot;/mnt/f/mattm/home/breezepms/hello-world&quot;,&quot;__sessionId&quot;:&quot;8e201eb7-88ec-452f-896d-3d5e98596c05&quot;}}
  2021-10-17T16:35:27+01:00 debug layer=dap debug backend is 'default'
  2021-10-17T16:35:27+01:00 debug layer=dap building program
  './hello-world.go' in '/mnt/f/mattm/home/breezepms/hello-world' with
  flags '' 2021-10-17T16:35:29+01:00 debug layer=dap running binary
  '/tmp/__debug_bin3449446367' in '.' 2021-10-17T16:35:29+01:00 info
  layer=debugger launching process with args:
  [/tmp/__debug_bin3449446367]</p>
  </blockquote>