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

相关推荐
l1t4 小时前
测试用go语言执行脚本把数据保存到SQLite数据库
数据库·golang·sqlite
golang学习记5 小时前
VS Code Agents新特性:标签页式工作区选择器
vscode
1024奇点7 小时前
【仓颉语言入门 · 第二篇 第 15 课】
开发语言·数据库·ide·开源
Agent世界7 小时前
千问Go上线我的应用:一句话生成可部署 AI 软件的技术拆解
开发语言·人工智能·golang·ai智能体
念何架构之路8 小时前
Go reflect包值操作 Value 的读写、可设置性与 interface 布局
开发语言·后端·golang
紧跟先前的步伐10 小时前
Go AI Agent 实战 18|Tool Calling 的基本原理与完整执行流程
前端·数据库·人工智能·ai·golang·1024程序员节
紧跟先前的步伐10 小时前
Go AI Agent 实战 17|模型适配层设计:让模型可替换
开发语言·人工智能·后端·ai·golang
l1t10 小时前
DeepSeek辅助编写连接sqlite的CLI
数据库·golang·sqlite
计算机就业还在扩大10 小时前
第2期-cmp.Ordered+类型推断+刻意未支持的特性
后端·面试·golang