环境
- 操作系统: macOS10.15.4
- golang版本: 1.13.8 (采用homebrew安装)
问题描述
- 写了一个打印出
hello world的go文件,在使用go run hello.go执行时报错cannot load fmt: malformed module path "fmt": missing dot in first path element - 在
$GOROOT/src目录中执行go install golang.org/x/lint/golint时报错build golang.org/x/lint/golint: cannot load bufio: malformed module path "bufio": missing dot in first path element
解决
golang的真实安装目录是在/usr/local/Cellar/go@1.13/1.13.8, 同时brew会软链该目录到/usr/local/opt/go@1.13, 之前是把$GOROOT环境变量设置成/usr/local/opt/go@1.13, 也就造成了上面的问题.
解决办法是把$GOROOT环境变量设置成/usr/local/opt/go@1.13/libexec目录, 即export GOROOT=/usr/local/opt/go@1.13/libexec
本文解决在macOS系统上配置Golang环境时遇到的错误,包括cannotloadfmt和missingdotinfirstpathelement等问题。通过调整$GOROOT环境变量至正确路径,实现Golang环境的正常运行。
8470

被折叠的 条评论
为什么被折叠?



