dlv远端调试go的问题

1.golang采用dlv 时提示 “could not launch process: could not open debug info ”

在用dlv 远程debug 代码时候,提示我“could not launch process: could not open debug info ”

经过一番搜索,参考:https://github.com/go-delve/delve/issues/1698 发现代码中的Makefile 文件中的build 带有 -s -w 参数。

2.需要执行本地编译的代码才可以调试,但是可能涉及到不同环境的编译
https://www.jianshu.com/p/b564a46d6267
  
  win 编译到mac,windowns
CGO_ENABLED=0 GOOS=darwin GOARCH=amd64 go build test.go
CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build test.go

3 本机命令行调试

本机只要输入:

dlv connect www.example.com:8181 连接到服务器上的dlv进程,就可以在本机远程调试了。

4. 安装dlv

一句话ok: go install  github.com/go-delve/delve/cmd/dlv

5.远端一句话

dlv debug --headless --listen=:2345 --api-version=2 hello.go

 

posted @ 2021-12-10 16:38  易先讯  阅读(1078)  评论(0编辑  收藏  举报