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

相关推荐
女王大人万岁10 小时前
Golang标准库 CGO 介绍与使用指南
服务器·开发语言·后端·golang
福大大架构师每日一题15 小时前
2026-01-15:下一个特殊回文数。用go语言,给定一个整数 n,求出一个比 n 更大的最小整数,该整数需要满足两条规则: 1. 它的十进制表示从左到右与从右到左完全一致(即读起来是对称的)。 2
python·算法·golang
Aerkui15 小时前
Go 泛型(Generics)详解
开发语言·后端·golang
clive.li15 小时前
go-webmvc框架推荐
开发语言·后端·golang
有代理ip15 小时前
常见数据采集问题及实操解决方案
爬虫·网络协议·http·golang·ssl
来两个炸鸡腿16 小时前
【Datawhale组队学习202602】Easy-Vibe task02 认识AI IDE工具
ide·人工智能·学习·大模型
风静如云16 小时前
VSCode:避免打开新文件时会在标签页覆盖旧文件
vscode
春日见21 小时前
如何查看我一共commit了多少个,是哪几个,如何回退到某一个版本
vscode·算法·docker·容器·自动驾驶
2501_941982051 天前
马年 Go 篇:高并发企微机器人开发实战
开发语言·golang·企业微信
Mr -老鬼1 天前
基于 Go 的脚本平台 APP 云控系统
开发语言·后端·golang