You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Windows下Neovim+nvim-dap-go调试Go代码遇dlv退出错误求助

Windows下Neovim+nvim-dap-go调试Go代码时dlv空指针panic问题

环境信息

  • 调试工具链:Neovim + nvim-dap + nvim-dap-go
  • 已安装dlv并在Neovim配置中指定路径,dlv在Neovim外的dap模式可正常运行
  • GOPATH、GOROOT、GOBIN环境变量配置正确

错误现象

启动调试会话时,go.exe命令行窗口短暂弹出后关闭,收到核心错误提示:

Debug adapter didn't respond. Either the adapter is slow (then wait and ignore this) or there is a problem with your adapter or go configuration. Check the logs for errors (dap.set_log_level)

执行:lua require('dap.repl').open()后,在REPL中看到dlv的stderr输出(空指针panic):

[debug-adapter stderr] panic: runtime error: invalid memory address or nil pointer dereference
[signal 0xc0000005 code=0x0 addr=0x38
[debug-adapter stderr]  pc=0x71d062]

goroutine 12 [running, locked to thread]:
github.com/go-delve/delve/pkg/proc/native.(*nativeProcess).addThread(0x0, 0x250, 0x28f8, 0xb0?, 0x0, 0x0)
/go/pkg/mod/github.com/go-delve/delve@v1.22.1/pkg/proc/native/proc_windows.go:302 +0x42
github.com/go-delve/delve/pkg/proc/native.(*processGroup).waitForDebugEvent(0xc000444de0, 0x1)
/go/pkg/mod/github.com/go-delve/delve@v1.22.1/pkg/proc/native/proc_windows.go:406 +0x5e7
github.com/go-delve/delve/pkg/proc/native.initialize.func1()
/go/pkg/mod/github.com/go-delve/delve@v1.22.1/pkg/proc/native/proc_windows.go:84 +0x25
github.com/go-delve/delve/pkg/proc/native.(*ptraceThread).handlePtraceFuncs(0xc000008888)
/go/pkg/mod/github.com/go-delve/delve@v1.22.1/pkg/proc/native/proc.go:405 +0x48
created by github.com/go-delve/delve/pkg/proc/native.newPtraceThread in goroutine 6
/go/pkg/mod/github.com/go-delve/delve@v1.22.1/pkg/proc/native/proc.go:492 +0xc6

dap日志内容

[ DEBUG ] 2024-05-26T18:57:47Z+0500 ] ...ppData/Local/nvim-data/lazy/nvim-dap/lua/dap/session.lua:957 ] 4   {
  body = {
    supportsClipboardContext = true,
    supportsConditionalBreakpoints = true,
    supportsConfigurationDoneRequest = true,
    supportsDelayedStackTraceLoading = true,
    supportsDisassembleRequest = true,
    supportsEvaluateForHovers = true,
    supportsExceptionInfoRequest = true,
    supportsFunctionBreakpoints = true,
    supportsInstructionBreakpoints = true,
    supportsLogPoints = true,
    supportsSetVariable = true,
    supportsSteppingGranularity = true
  },
  command = "initialize",
  request_seq = 1,
  seq = 0,
  success = true,
  type = "response"
}
[ DEBUG ] 2024-05-26T18:57:47Z+0500 ] ...ppData/Local/nvim-data/lazy/nvim-dap/lua/dap/session.lua:1700 ]    "request"   {
  arguments = {
    args = { "-test.run", "^Test_reorderList$" },
    buildFlags = "",
    mode = "test",
    name = "Test_reorderList",
    program = "./linkedlist",
    request = "launch",
    type = "go"
  },
  command = "launch",
  seq = 2,
  type = "request"
}

Neovim插件配置(plugins/init.lua)

{
    "mfussenegger/nvim-dap",
 },

 {
    "leoluz/nvim-dap-go",
    ft = "go",
    dependencies = { "mfussenegger/nvim-dap" },
    config = function(_, opts)
      require("dap-go").setup(opts)
      require('dap').set_log_level('TRACE')
    end,
 },

 {
    "rcarriga/nvim-dap-ui",
    dependencies = {
      "mfussenegger/nvim-dap",
      "nvim-neotest/nvim-nio",
    },
 },

  {
    "theHamsta/nvim-dap-virtual-text",
  },

已尝试的解决措施

  • 重装所有相关插件
  • 多次验证GOPATH、GOROOT、GOBIN等环境变量的正确性
  • 重启系统
  • 相同版本的Go、dlv、Neovim及配置在Linux Ubuntu环境下可正常调试,无此问题

目前仍无法启动调试会话,寻求解决方案。

内容的提问来源于stack exchange,提问作者Trypo Phobia

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.06.23 05:53:16