From 2dc7cb40457b5dcec761ca6121ba14d63e71073c Mon Sep 17 00:00:00 2001 From: "lion.chan" Date: Tue, 7 Mar 2023 20:04:14 +0800 Subject: [PATCH] =?UTF-8?q?=E5=AE=8C=E5=96=84=20dlv=20=E8=B0=83=E8=AF=95?= =?UTF-8?q?=E5=91=BD=E4=BB=A4.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: lion.chan --- .../Go/Debug/VSCode_调试_Golang_无法_Input_问题的解决.md | 9 +++++++-- .../Language/Go/Package/Delve/Go_dlv_远程调试.md | 2 ++ 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/Software/Development/Language/Go/Debug/VSCode_调试_Golang_无法_Input_问题的解决.md b/Software/Development/Language/Go/Debug/VSCode_调试_Golang_无法_Input_问题的解决.md index 087bd1c..14376ee 100644 --- a/Software/Development/Language/Go/Debug/VSCode_调试_Golang_无法_Input_问题的解决.md +++ b/Software/Development/Language/Go/Debug/VSCode_调试_Golang_无法_Input_问题的解决.md @@ -1,9 +1,11 @@ # VSCode 调试 Golang 无法 Input 问题的解决 -解决办法就是不用 VSCode 的调试终端,在命令行里使用 DLV 开启服务,然后使用 VSCode 作为调试 Client 进行连接,则可在 DLV 调试命令行里输入 +解决办法就是不用 VSCode 的调试终端,在命令行里使用 DLV 开启服务,然后使用 VSCode 作为调试 Client 进行连接,则可在 DLV 调试命令行里输入: ```bash -dlv exec --headless --api-version=2 -l ":" -- +dlv debug --headless --api-version=2 -l ":" -- +# 如 +dlv debug --headless --api-version=2 -l "127.0.0.1:2345" -- -a demo ``` VSCode 的 launch.json 如下: @@ -19,6 +21,7 @@ VSCode 的 launch.json 如下: "name": "Connect to server", "type": "go", "request": "attach", + "debugAdapter": "dlv-dap", "mode": "remote", "remotePath": "${workspaceFolder}", "port": 2345, @@ -27,3 +30,5 @@ VSCode 的 launch.json 如下: ] } ``` + +然后在 VSCode 中打开 main.go,按 F5 进入调试即可。 diff --git a/Software/Development/Language/Go/Package/Delve/Go_dlv_远程调试.md b/Software/Development/Language/Go/Package/Delve/Go_dlv_远程调试.md index 9fc52b6..ddd080a 100644 --- a/Software/Development/Language/Go/Package/Delve/Go_dlv_远程调试.md +++ b/Software/Development/Language/Go/Package/Delve/Go_dlv_远程调试.md @@ -1,6 +1,8 @@ # Go dlv 远程调试 ```bash +dlv debug --headless --api-version=2 -l ":" -- +# 或 dlv exec --headless --api-version=2 -l ":" -- ```