英文:
golang go get unrecognized import path
问题
当我尝试在golang项目的根路径ChaatzFeaturePhoneServer中运行go get时,它提示:
go get
package FeaturePhoneServer/routers: unrecognized import path "FeaturePhoneServer/routers"
我对此感到相当困惑。可能的原因是什么?我该如何找出原因并修复它?
英文:
When I tried to run go get in a golang project root path ChaatzFeaturePhoneServer. It prompts
go get
package FeaturePhoneServer/routers: unrecognized import path "FeaturePhoneServer/routers"
I am rather confused about it. What is the possible cause of it? How can I find out the cause and fix it?
答案1
得分: 6
请检查您的GOPATH环境变量:
go期望在$GOPATH/src中找到FeaturePhoneServer/routers(参见go build)。
避免使用相对导入路径避免相对导入路径。
如果错误仍然存在,您还可以检查您的GOROOT和go安装,如此问题中所述。
英文:
Check your GOPATH environment variable:
go expect to find FeaturePhoneServer/routers in $GOPATH/src (see go build)
Avoid relative import paths.
If the error persists, you can also check your GOROOT and go installation, as in this question.
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。


评论