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

相关推荐
你家人养牛19 小时前
OOC Relation Plugin:C 语言面向对象 开发的高效辅助工具
c语言·vscode
林熙蕾LXL19 小时前
VSCode调试
ide·vscode·编辑器
想你依然心痛20 小时前
AtomCode在后端开发中的实战体验:Go微服务从零搭建
开发语言·微服务·golang
测试工程师成长之路20 小时前
Typora插件开发指南:打造专属IDE式写作环境
ide
开发小程序的之朴21 小时前
认识安企CMS - 系统概述
nginx·golang·系统架构
雨师@21 小时前
go语言项目--实例化(图书管理)--005
开发语言·后端·golang
菜地里的小菜鸟21 小时前
vscode接入claudecode
vscode·claude code·vscode接入claudecode
Vect__21 小时前
Go 数据结构 slice 深度剖析
开发语言·数据结构·golang
geovindu21 小时前
go: Functional Options Pattern
开发语言·后端·设计模式·golang·函数式选项模式’·惯用法模式
π同学1 天前
ESP-IDF+vscode开发ESP32第十七讲——USB设备栈
vscode·esp32·usb