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

相关推荐
2601_962294614 小时前
Python开发工具哪个好?Python开发工具推荐
ide·文本编辑器·游戏开发·编程语言·python开发工具
techdashen10 小时前
Go Map 详解:键值对实际上是如何存储的
开发语言·后端·golang
执明wa11 小时前
Android Studio 打包 APK
android·ide·android studio
ttwuai14 小时前
Go 后台初始化 MySQL 脚本失败怎么办?先查 DDL 还是生成配置
开发语言·mysql·golang
名字还没想好☜14 小时前
Go 的 TCP 粘包与拆包:用长度前缀协议 + bufio 正确读消息
后端·tcp/ip·golang·go·php
好悬给我拽开线15 小时前
RoboTTT
ide·vscode·编辑器
2601_9622946117 小时前
Python工具软件开发:借助InsCode AI IDE开启智能编程新时代
ide·python·ai·开发工具·智能化编程
王的宝库1 天前
Go 项目结构:从单文件到标准工程布局
开发语言·后端·golang
花酒锄作田1 天前
Go - Gin中使用sessions
golang
不甘先生1 天前
Go 中 type、方法与指针接收者:从 str_name.Name() 看懂 Go 的类型系统
开发语言·后端·golang