windows系统使用Vscode在WSL调试golang本地进程

背景:

windows10企业版

vscode+golang1.20

wsl编译运行。

vscode 使用本地wsl进行进程attach操作,发现:Access is denied.

本地进程启动,vscode调试进程。windows-Linux控制台:

bash 复制代码
Starting: C:\Users\book\go\bin\dlv.exe dap --listen=127.0.0.1:61732 from D:\test\job
DAP server listening at: 127.0.0.1:61732

表明:使用的是windows配置环境(dlv.exe)

解决方案:切换WSL环境:

  • 点击:><

  • 切换:

  • 显示:

    此时lauch.json运行使用的是wsl环境(dlv)

bash 复制代码
Starting: /home/book/go/bin/dlv dap --listen=127.0.0.1:63282 --log-dest=3 from /mnt/d/test/job
DAP server listening at: 127.0.0.1:63282
closing connection from different user (127.0.0.1:63284): connections to localhost are only accepted from the same UNIX user for security reasons
2024-02-27T17:08:35+08:00 error layer=dap Error accepting client connection: Only connections from the same user that started this instance of Delve are allowed to connect. See --only-same-user.
dlv dap (17665) exited with code: 0

报错原有是:用户不同

ref:

https://blog.csdn.net/qq_58307541/article/details/125738589

https://stackoverflow.com/questions/69442767/how-can-i-fix-the-vscode-debuger-in-vscode

相关推荐
Howrun7772 小时前
VSCode烦人的远程交互UI讲解
ide·vue.js·vscode
Ashley的成长之路3 小时前
2025 年最新:VSCode 中提升 React 开发效率的必备插件大全
ide·vscode·react.js·工作提效·react扩展
m0_555762903 小时前
VSCODE CLAUDE CODE
ide·vscode·编辑器
2501_941982057 小时前
深度对比:Java、Go、Python 实现企微外部群推送,哪个效率更高?
java·golang·企业微信
悟能不能悟8 小时前
如何打开2个notepad++
ide
wVelpro10 小时前
如何在Pycharm 2025.3 版本实现虚拟环境“Make available to all projects”
linux·ide·pycharm
jun_bai12 小时前
VSCode使用
ide·vscode·编辑器
参.商.13 小时前
【Day 27】121.买卖股票的最佳时机 122.买卖股票的最佳时机II
leetcode·golang
牛奔13 小时前
如何理解 Go 的调度模型,以及 G / M / P 各自的职责
开发语言·后端·golang
猫头虎14 小时前
OpenClaw-VSCode:在 VS Code 里玩转 OpenClaw,远程管理+SSH 双剑合璧
ide·vscode·开源·ssh·github·aigc·ai编程