现象

在一些init函数中打下断点,执行时达到断点后,Debug Console 输出一下信息后会直接结束,无法继续进行调试

1
2
3
4
5
Unhandled error in debug adapter: TypeError: Cannot read properties of undefined (reading 'addr')
at GoDebugSession.convertDebugVariableToProtocolVariable (/root/.vscode-server/extensions/golang.go-0.37.1/dist/debugAdapter.js:16728:25)
at /root/.vscode-server/extensions/golang.go-0.37.1/dist/debugAdapter.js:16249:55
at processTicksAndRejections (node:internal/process/task_queues:96:5)
at async Promise.all (index 2)

修复方案

根据找到vscode golang插件源码,ignore undefined的情况:

https://kevinello-1302687393.file.myqcloud.com/picgo/2023/02/27/202302271603668-07bf1b.png

目前已通过PR合入vscode主干,将在0.38.0正式发布

https://kevinello-1302687393.file.myqcloud.com/picgo/2023/02/28/Untitled-ffaded.png