MENU

macOS中vscode调试golang程序报错

November 10, 2024 • 编程语言,MacOSX

问题

image.png

$ go version
go version go1.22.3 darwin/arm64

$ clang --version
Apple clang version 16.0.0 (clang-1600.0.26.4)
Target: arm64-apple-darwin23.6.0
Thread model: posix

$ ld -v
@(#)PROGRAM:ld PROJECT:ld-1115.7.3

$ dsymutil -v
Apple LLVM version 16.0.0
   (clang-1600.0.26.4)Optimized build.

$ /usr/bin/xcodebuild -version 
Xcode 16.1
Build version 16B40

launch.json配置中添加env配置项也无效:

{
    // 使用 IntelliSense 了解相关属性。 
    // 悬停以查看现有属性的描述。
    // 欲了解更多信息,请访问: https://go.microsoft.com/fwlink/?linkid=830387
    "version": "0.2.0",
    "configurations": [
        {
            "name": "Launch Package",
            "type": "go",
            "request": "launch",
            "mode": "auto",
            "program": "${fileDirname}",
            "env": {
                "CC": "/usr/bin/cc",
                "CXX": "/usr/bin/c++",
            }
        }
    ]
}

解决

升级golang1.22.9即可

资料

https://github.com/go-delve/delve/issues/3701