最近安装了go语言的环境,结果出现了问题,首先交代一下我的电脑是macbook pro M1 pro的芯片,也就是要用arm架构的包,但是这个其实没有啥区别。
用homebrew安装好了go以后,在vscode里面搞了配置,装组件这些暂且不表。
编译第一个go 的helloworld程序的时候出现了问题
这个问题我首先看报错的原因是版本不对,然后在homebrew升级了版本
brew upgdate go
升级到1.20.6了
之后还是报这个错,查了俩小时,在stackoverflow里面找到了解决方案;
For M1 Mac, the following steps helped me!
Check for which go from VSCode Terminal and check from system terminal.
from vscode terminal
user@mac % which go
/usr/local/go/bin/go
from my mac terminal
user@mac % which go
/opt/homebrew/bin/go
Whichever corresponds to the GOROOT shown go env, keep it and delete the other one
user@mac % go env GOROOT
/usr/local/go
in this case
rm -rf /opt/homebrew/bin/go
close and reload the vscode and terminal
</