gpt4 book ai didi

delve - golang dlv 无法看到源::没有这样的文件或目录

转载 作者:行者123 更新时间:2023-12-04 15:51:29 26 4
gpt4 key购买 nike

在 docker 容器中:

docker run \
--rm -it \
-p 80:80 \
-p 2345:2345 \
-v $(pwd)/src:/go/src/ \
--security-opt="seccomp=unconfined" \
--privileged \
--cap-add SYS_PTRACE \
golang bash

在 $GOPATH 的容器中:

go get -u github.com/derekparker/delve/cmd/dlv

dlv version
Delve Debugger
Version: 1.1.0
Build: $Id: 1990ba12450cab9425a2ae62e6ab988725023d5c

dlv debug app --headless --listen=0.0.0.0:2345 --api-version=2

在 $GOPATH::的 mac 终端中

dlv version
Delve Debugger
Version: 1.1.0
Build: $Id: 1990ba12450cab9425a2ae62e6ab988725023d5c $

dlv connect 127.0.0.1:2345

我得到以下信息,但无法列出来源?

dlv connect 127.0.0.1:2345
Type 'help' for list of commands.
(dlv) b main.go:29
Breakpoint 1 set at 0x7f584d for main.main.func1() /go/src/app/main.go:29
(dlv) c
> main.main.func1() /go/src/app/main.go:29 (hits goroutine(4):1 total:1) (PC: 0x7f584d)
(dlv) l
> main.main.func1() /go/src/app/main.go:29 (hits goroutine(4):1 total:1) (PC: 0x7f584d)
Command failed: open /go/src/app/main.go: no such file or directory

注意:我在 dlv 服务器和客户端中都在 $GOPATH 中:

在容器中:

ls $GOPATH/src/app
layout.html main.go mypack

在 mac 终端中:

ls $GOPATH/src/app
layout.html main.go mypack

对比代码 launch.json:

{
// Use IntelliSense to learn about possible attributes.
// Hover to view descriptions of existing attributes.
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
"name": "Connect to server",
"type": "go",
"request": "launch",
"mode": "remote",
"remotePath": "${workspaceFolder}",
"port": 2345,
"host": "127.0.0.1",
"program": "${workspaceFolder}",
"env": {},
"args": [],
"trace": "verbose"
},
]
}

最佳答案

参见 https://github.com/go-delve/delve/issues/1438 .解决方案是将其放入$HOME/.dlv/config.yml:

替代路径: - {从:/,到:/root}

关于delve - golang dlv 无法看到源::没有这样的文件或目录,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/53621853/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com