现象:m1芯片无法正常使用vscode的debug工具,报错: 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
1、检查是否已安装或安装过amd版本的go
之前安装的是amd版本的go,而苹果m1系列使用的是darwin/arm64,需要重新安装arm64版本的go,下载darwin-arm64.pkg包,直接安装就能更新为arm架构的go了。
至此,go已经没问题了,但是我在debug时依然报标题上的错误,原因是我在使用amd版本go的时候安装了dlv工具,这是debug需要的工具,然而它被安装成了amd版本的,所以依然报错。
2、修复dlv
由于我的$GOPATH/bin下的软件包都是amd版本的,直接将bin目录下的内容全部清空,然后在vscode执行Go: Install/Update Tools
,按住"commond+shift+p"打开extention,找到“Go: Install/Update Tools”执行即可