【GoLand】无法debug 无法运行

GoLand,点击debug报错:

复制代码
GOROOT=/Users/tiantian19/sdk/go1.21.9 #gosetup
GOPATH=/Users/tiantian19/go #gosetup
/Users/tiantian19/sdk/go1.21.9/bin/go build -o /Users/tiantian19/Library/Caches/JetBrains/GoLand2023.1/tmp/GoLand/___go_build_icode_baidu_com_baidu_cov_smartUT_comate -gcflags all=-N -l icode.baidu.com/baidu/cov/smartUT-comate #gosetup
/Applications/GoLand.app/Contents/plugins/go-plugin/lib/dlv/macarm/dlv --listen=127.0.0.1:58724 --headless=true --api-version=2 --check-go-version=false --only-same-user=false exec /Users/tiantian19/Library/Caches/JetBrains/GoLand2023.1/tmp/GoLand/___go_build_icode_baidu_com_baidu_cov_smartUT_comate --
API server listening at: 127.0.0.1:58724
debugserver-@(#)PROGRAM:LLDB  PROJECT:lldb-1600.0.39.109
 for arm64.
Got a connection, launched process /Users/tiantian19/Library/Caches/JetBrains/GoLand2023.1/tmp/GoLand/___go_build_icode_baidu_com_baidu_cov_smartUT_comate (pid = 81255).
Exiting.
could not launch process: decoding dwarf section info at offset 0x0: too short - debuggee must not be built with 'go run' or -ldflags='-s -w', which strip debug info

Debugger finished with the exit code 1

解决方法:

升级dlv

  1. 下载delve
    git clone https://github.com/go-delve/delve
    cd /delve/cmd/dlv 进入build目录,
    go build main.go 编译main.go并生成可执行文件main (这里要确保工作用户与目录的权限一致,否则无法编译)
    mv main dlv 修改可执行文件名
  2. 替换goland dlv

查出dlv路径 需要golang执行一下debug

ps -ef|grep dlv

替换dlv

拷贝旧的debug文件,将新的dlv替换旧的

/Applications/GoLand.app/Contents/plugins/go-plugin/lib/dlv/macarm/dlv

如果还不能debug

查看GoLand中使用的go版本与工程go mod文件中指定版本是否一致

相关推荐
爱学习的小邓同学2 小时前
Golang --- (1)第一个Golang程序
开发语言·后端·golang
路多辛7 小时前
全能型 Agent covo-agent v0.0.7 发布:TUI 新增 LLM 内联自动补全
golang
圣殿骑士-Khtangc8 小时前
Gin优雅关停与平滑重启从零停机到热更新
golang·gin
程序员z79 小时前
深入理解 GMP 模型:Go 协程调度器的设计与调度场景全解析
服务器·网络·golang
爱学习的小邓同学9 小时前
Golang语言入门
开发语言·后端·golang
路多辛11 小时前
全能型 Go Agent 框架 covonaut v1.0.8 发布:新增行内补全与多后端可观测性
开发语言·golang·agent
FfHUCisI13 小时前
Golang Redis 分布式锁
redis·分布式·golang
newerp14 小时前
语法分析与 AST:Parser 与 go/ast
后端·程序员·go
newerp14 小时前
Go 编译过程全景
后端·程序员·go
圣殿骑士-Khtangc14 小时前
Go-Channel底层结构深度解析与select多路复用机制
golang