我发现一个遇到同样问题的主题(Can't debug Golang in vscode apple m1)但我不确定它是否是一个旧的解决方案,因为我使用的是 Go 版本
go1.17.1 darwin/arm64
Run Code Online (Sandbox Code Playgroud)
和
dlv version 1.7.2
Run Code Online (Sandbox Code Playgroud)
和
VSCode version 1.60.2 (arm64)
Run Code Online (Sandbox Code Playgroud)
在
Mac M1 BigSur (11.6)
Run Code Online (Sandbox Code Playgroud)
当我运行 debug ( fn+f5) 时,调试控制台显示:
Starting: /Users/username/go/bin/dlv-dap dap --check-go-version=false --listen=127.0.0.1:53115 --log-dest=3 from /Users/username/go/src/project-name
DAP server listening at: 127.0.0.1:53115
Run Code Online (Sandbox Code Playgroud)
并且出现弹出错误:
Failed to launch: could not launch process: can not run under Rosetta, check that the installed build of Go is right for your CPU architecture
Run Code Online (Sandbox Code Playgroud)
我尝试使用 dlv 1.6.1 将 go 版本降级到 1.16.8 arm64 …