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

相关推荐
_小许_2 小时前
Go语言实现HTML转PDF
golang·pdf·html
老程序员刘飞6 小时前
vscode 连接 wsl
ide·vscode·编辑器
图亚Vanta6 小时前
Python入门第一课:Python安装、VSCode/Pycharm配置
vscode·python·pycharm
半路程序员8 小时前
Go语言学习(四)
开发语言·学习·golang
秦禹辰8 小时前
轻量级开源文件共享系统PicoShare本地部署并实现公网环境文件共享
开发语言·后端·golang
数据知道12 小时前
Go基础:一文掌握Go语言泛型的使用
开发语言·后端·golang·go语言
马儿能够一直跑13 小时前
基于vscode在WSL中配置PlatformIO开发环境
ide·vscode·编辑器
止观止13 小时前
VS Code 二次开发:跨平台图标定制全攻略
linux·windows·vscode·macos
Dontla13 小时前
VSCode括号高亮插件(vscode插件)bracket pair、活动括号对、括号线(未完全检查)
ide·vscode·编辑器
动态一时爽,重构火葬场14 小时前
Kubernetes 之海,Go 之舟:避开那些吞噬性能的隐形暗礁
容器·golang·kubernetes