從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命令。目錄下會生成兩個文件。就可以解決上面出現的raycast.go: package raycast/engine is not in GOROOT (D:\Go\src\raycast\engine)錯誤
go.mod
go.sum
注意:go mod init后面所跟的名稱raycastergo必須與項目名稱raycastergo一致

否則會報錯:
raycast.go: package raycast/engine is not in GOROOT (D:\Go\src\raycast/engine)
