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

相关推荐
灯澜忆梦14 小时前
【基于GO的Web开发3】gin框架_HTML渲染
前端·golang·gin
精英的英1 天前
记一次 Qt5 Language Server 开发
开发语言·vscode·qt
码农大叔的博客1 天前
golang示例:switch
开发语言·后端·golang
圣殿骑士-Khtangc1 天前
Go面试核心考点之GMP调度器源码级深度解析
golang
2501_915918412 天前
iOS 真机调试工具推荐,安装运行、性能分析有哪些工具
ide·vscode·ios·objective-c·个人开发·swift·敏捷流程
xcLeigh2 天前
Go入门:无类型常量与类型常量的区别
服务器·开发语言·golang
泡沫冰@2 天前
GO 语言基础
开发语言·算法·golang
笨鸟先飞,勤能补拙2 天前
AI与深度学习:从原理到应用
人工智能·windows·vscode·深度学习·机器学习·网络安全·github
Albert Edison2 天前
PyCharm 字体大小设置
ide·python·pycharm
格数致用2 天前
银河麒麟 V10 SP1 桌面操作系统 + VSCode + Claude Code 接入 DeepSeek-V4 全流程教程(2026年最新)
vscode·claudecode·银河麒麟 v10