升级MacOS Sequoia后VSCode调试Go测试报错求助
解决MacOS Sequoia下VSCode调试Go测试的DWARF错误
问题背景
升级MacOS至Sequoia后,使用VSCode调试Go测试时出现以下错误:
Failed to launch: could not launch process: error reading debug_info: decoding dwarf section info at offset 0xac6f38: DW_FORM_strx with no .debug_str_offsets section
环境配置:dlv 1.23.0,Go 1.22.7 darwin/arm64,已尝试-gcflags="all=-N -l"、重装Go和dlv但未解决。
解决办法
升级Delve到最新兼容版本
旧版dlv对Sequoia的DWARF格式支持存在问题,执行以下命令安装最新版:go install github.com/go-delve/delve/cmd/dlv@latest安装完成后替换系统中旧的dlv可执行文件。
升级Go到最新稳定版
Go 1.22.7未针对Sequoia做适配,升级到官方最新稳定版(如1.23.x),重新安装后重新编译测试代码。调整VSCode调试配置
在项目的.vscode/launch.json中修改调试配置,添加dlvFlags跳过版本检查:{ "version": "0.2.0", "configurations": [ { "name": "Launch Test", "type": "go", "request": "launch", "mode": "test", "program": "${file}", "dlvFlags": ["--check-go-version=false"] } ] }清理Go缓存
执行以下命令清理模块缓存和编译缓存,避免旧缓存导致的兼容性问题:go clean -modcache go clean -cache更新VSCode Go插件
在VSCode扩展市场中找到「Go」插件(由Go Team at Google开发),检查并更新到最新版本,新版本通常会修复新系统的适配问题。
内容的提问来源于stack exchange,提问作者Harith Laxman
相关产品推荐
相关产品推荐

