登录
首页 >  Golang >  Go问答

IntelliJ 发现 git 存储库中的 origin 对象错误,建议使用 go get 安装模块

来源:stackoverflow

时间:2024-03-27 17:45:29 143浏览 收藏

最近发现不少小伙伴都对Golang很感兴趣,所以今天继续给大家介绍Golang相关的知识,本文《IntelliJ 发现 git 存储库中的 origin 对象错误,建议使用 go get 安装模块》主要内容涉及到等等知识点,希望能帮到你!当然如果阅读本文时存在不同想法,可以在评论中表达,但是请勿使用过激的措辞~

问题内容

我尝试在我的 intellij 终端中使用以下命令在我的 go 项目上安装 [prometheus][1]:

go get github.com/prometheus/client_golang/prometheus

当我这样做时,我收到以下错误:

GOROOT=/usr/lib/golang #gosetup
GOPATH=/home/yakiza #gosetup
/usr/lib/golang/bin/go list -modfile=/home/yakiza/IdeaProjects/Zephyros/go.mod -m -json -mod=mod all #gosetup
go: github.com/prometheus/[email protected] requires
    github.com/prometheus/[email protected] requires
    golang.org/x/[email protected] requires
    cloud.google.com/[email protected] requires
    github.com/google/[email protected] requires
    github.com/chzyer/[email protected]: invalid version: git fetch -f origin refs/heads/*:refs/heads/* refs/tags/*:refs/tags/* in /home/yakiza/pkg/mod/cache/vcs/2b1d73c01d25b37519a4c8fa4a9da66549ac9cb349c7eed83e8fc258c189ca92: exit status 128:
    fatal: 'origin' does not appear to be a git repository
    fatal: Could not read from remote repository.
    
    Please make sure you have the correct access rights
    and the repository exists.

我注意到,如果我继续尝试使用终端(不在 ide 内部)安装模块,所有内容都会正确安装,但是当我使用 ide 打开项目时,错误仍然存​​在,并且我无法运行我的项目成功。

我尝试从项目中删除包,但没有成功。另外尝试使用 intellij 在另一个项目上安装该模块,遇到同样的问题。 [1]:https://prometheus.io/docs/guides/go-application/


正确答案


我到处寻找解决方案,但不幸的是我无法找到根本原因。

我可以肯定地说这是 IntelliJ 中的某些原因导致了这种情况,其原因是我 restored the IDE settings

从主菜单中,选择文件|管理 IDE 设置 |恢复默认设置。

然后重新启动我的 IDE,一切都按预期工作

以上就是《IntelliJ 发现 git 存储库中的 origin 对象错误,建议使用 go get 安装模块》的详细内容,更多关于的资料请关注golang学习网公众号!

声明:本文转载于:stackoverflow 如有侵犯,请联系study_golang@163.com删除
相关阅读
更多>
最新阅读
更多>
课程推荐
更多>