英文:
Go Build with Debug mode in Visaul Studio Code
问题
问题不是如何调试,而是如何在特定架构和版本上设置调试器。
我不想在没有Rosetta的情况下更新Go,它必须在相同的设置上运行。
这是我的系统:
- Go版本1.16(不是最新版本)
- Mac M1,使用Rosetta终端。
这是launch.json
文件的内容:
{
"version": "0.2.0",
"configurations": [
{
"name": "Launch",
"type": "go",
"request": "launch",
"mode": "debug",
"remotePath": "",
"program": "${workspaceRoot}",
"env": {},
"args": [],
"showLog": true
}
]
}
英文:
Question is not to how to debug, It's like how to set up debugger on architecture and version.
I don't want to update go without rosetta, It has to be run on same set up.
Here is system,
- Go version 1.16 (Not the latest one)
- Mac M1 with Rosetta Terminal.
Here is
> launch.json
file.
{
// Use IntelliSense to learn about possible attributes.
// Hover to view descriptions of existing attributes.
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
"name": "Launch",
"type": "go",
"request": "launch",
"mode": "debug",
"remotePath": "",
"program": "${workspaceRoot}",
"env": {},
"args": [],
"showLog": true
}
]
}
答案1
得分: 1
根据错误信息所示,请确保你的Go工具和VSCode都是适用于M1芯片(darwin/arm64)的版本。
英文:
As the error message indicates, make sure your Go tools AND VSCode are the versions for M1 (darwin/arm64).
答案2
得分: 0
我在几周前在我的Macbook Pro M1上使用VS Code调试应用程序时遇到了相同的问题,而且没有进行任何额外的配置。我通过以下步骤解决了这个问题(希望对其他人有所帮助):
- 使用来自https://golang.org的ARM64安装包重新安装GO - https://go.dev/dl/go1.18.darwin-arm64.pkg(安装程序已经处理了删除先前版本的工作)
- 重新安装您的Go Visual Code扩展
- 重新安装Delve(用于Go的调试器),您可以通过在命令行中运行
go install github.com/go-delve/delve/cmd/dlv@latest
来完成。 - 重新安装gDelve(用于Delve的GUI),您可以通过在命令行中运行
go install github.com/aarzilli/gdlv@latest
来完成。 - 重新启动您的VS Code
尽管第一步应该足以与M1处理器架构完全兼容,但仅此还不足以使用VS Code调试应用程序,因为先前安装的Delve版本可能不正确。
英文:
I had the same issue debugging an application on my Macbook Pro M1 a few weeks using VS Code, without any extra configuration. I was able to fix it with this steps (in case it helps someone else)
- Reinstall GO using the ARM64 installation package from https://golang.org - https://go.dev/dl/go1.18.darwin-arm64.pkg (the installer already takes care of removing the previous version )
- Reinstall your Go Visual Code Extensions
- Reinstall Delve (debugger for go), you can do it by running
go install github.com/go-delve/delve/cmd/dlv@latest
from the command line. - Reinstall gDelve (GUI for delve), you can do this by running
go install github.com/aarzilli/gdlv@latest
from the command line. - Restart your VS Code
Although step one should be more than enough to have full compatibility with the M1 processor architecture, it is not enough to debug the applications using VS Code, since the previously installed version of Delve may not be the correct one.
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论