从github上下载golang项目到本地运行go build编译,IDE上显示raycast.go: package raycast/engine is not in GOROOT (D:\Go\src\raycast\engine)错误
下面是项目结构:
golang使用gopath后者gomod模式经行包管理,我使用gomod模式
export GO111MODULE=on
在E:\raycastergo\目录下运行go mod init raycastergo与go mod tidy命令。目录下会生成两个文件.上述出现的问题就就解决了。
go.mod go.sum
注意:go mod init后面所跟的名称`raycastergo必须与项目名称raycastergo一致
否则会报错:
raycast.go: package raycast/engine is not in GOROOT (D:\Go\src\raycast/engine)
本文介绍了如何在使用golang的gopath或gomod模式时,正确配置项目结构并解决`raycast.go:packageraycast/engineisnotinGOROOT`错误,包括设置GO111MODULE、初始化go.mod和go.sum,以及确保包路径的正确性。

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



