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

相关推荐
badhope21 小时前
Docker从零开始安装配置全攻略
运维·人工智能·vscode·python·docker·容器·github
biubiubiu07061 天前
VScode查看插件相关问题
ide·vscode·编辑器
Penguido1 天前
解决 VS Code 中 Git 推送报错:ECONNREFUSED vscode-git.sock 与鉴权失败
linux·git·vscode
王的宝库1 天前
Go 语言:结构体:定义、初始化、方法、组合、Tag、对齐
开发语言·后端·学习·golang
河边小咸鱼1 天前
pdd校招实习生内推【实时更新链接】2027届实习、2026届春招
java·c++·golang
程序员鱼皮1 天前
VSCode + Copilot 保姆级 AI 编程实战教程,免费用 Claude,夯爆了!
vscode·ai·程序员·编程·ai编程
BagMM1 天前
VScode 使用 Codex插件(避坑!)
ide·vscode·编辑器
山川行1 天前
Git学习笔记:Git进阶操作
笔记·git·vscode·学习·编辑器·visual studio code
Java面试题总结1 天前
Go运行时系统解析: runtime包深度指南
开发语言·后端·golang
有浔则灵1 天前
Go 语言 net/http 包详解:从入门到实战
http·golang·xcode