您的当前位置:首页正文

go run 报错:package XXX is not in GOROOT

2024-11-22 来源:个人技术集锦

go run时报错

package test1/pkg is not in GOROOT

 

原因:
  go.mod 中的module不匹配,因为项目名冲突我把项目名从test改成了test1,但go.mod文件中的module没有对应改成test1,所以导致了包找不到。
 
 
解决
  把go.mod文件中的module修改成test1,然后go mod tidy后重新运行。

 

参考链接:
https://blog.miuyun.work/archives/15303621

显示全文