【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文件中指定版本是否一致

相关推荐
北漂Zachary2 分钟前
四大编程语言终极对决:汇编/C#/Go/Java谁更强
汇编·golang·c#
Stark-C27 分钟前
NAS音乐必备神器,全平台音乐收割机!极空间部署『Go Music DL』
开发语言·后端·golang
不会敲代码14 小时前
从零开始学 Go:协程并发与 Web 开发初探
go
扉页的墨5 小时前
Wails v2 实战:用 Go 写桌面应用,从 0 到 1 构建一个本地笔记工具
go
ALex_zry6 小时前
go-zero Redis缓存封装与Model层设计
redis·缓存·golang·气象
我叫黑大帅6 小时前
从零实现一个完整 RAG 系统:基于 Eino 框架的检索增强生成实战
后端·面试·go
XMYX-021 小时前
17 - Go 通道 Channel 底层原理 + 实战详解
开发语言·golang
不会写DN1 天前
通过eino-ext如何正常indexer RAG?
网络·面试·go
donecoding1 天前
遗嘱、水管与抢救室:TS 切入 Go 的流程控制、接口与并发
javascript·typescript·go
Tomhex1 天前
Go调用C代码的场景与实践
golang