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

相关推荐
sphw17 小时前
nixnb: Jupyter Notebook 优雅分享
ide·人工智能·jupyter
Achou.Wang18 小时前
深入理解go语言-第5章 并发编程——Go的灵魂
大数据·算法·golang
名字还没想好☜21 小时前
Go 的 time.After 在 select 循环里内存泄漏:定时器堆积原理与 timer.Reset 正确姿势
java·数据库·golang·go·goroutine
ttwuai1 天前
GoFrame 后台日志清空失败:无 WHERE 删除为什么被拦住
前端·golang
进击的程序猿~1 天前
Go 并发底层原理面试学习指南
开发语言·面试·golang
不在逃避q1 天前
Golang笔记之Redis
redis·笔记·golang
计算机内卷的N天1 天前
CMake与Visual Studio的使用
c++·ide·visual studio
咱入行浅1 天前
一款实用的 Visual Studio 发布部署插件,助力提高部署效率!
ide·visual studio
geovindu1 天前
go:loghelper
开发语言·后端·golang
谢斯1 天前
[vscode] 使用unity打开vscode的取消.csproj的显示
ide·vscode·unity