【问题标题】:the "hero" component of iris not installed when using "dep" to manage project dependencies使用“dep”管理项目依赖时,没有安装 iris 的“hero”组件
【发布时间】:2019-03-02 10:57:08
【问题描述】:

这个问题也发布在这里:https://github.com/kataras/iris/issues/1081

我在我的 golang 项目中使用“iris”作为 MVC 框架,并使用“dep”来管理我的项目的依赖项。

“iris”依赖项在“Gopkg.toml”中配置如下:

后来我使用“dep ensure -v”下载所有依赖项。

“确保”命令完成后,我检查“vendor/github.com/kataras/iris/hero”文件夹中的下载文件,我发现没有下载源代码文件,请参阅下面的屏幕截图:

所以我不能在我的项目中使用“英雄”组件,因为我的项目中没有安装“英雄”相关的包。

感谢大家的帮助~

【问题讨论】:

  • 只是为了确认。这是在$GOPATH?对吗?
  • @HamzaAnis 是的,它在我的 $GOPATH 中。除“hero”组件外,所有其他“iris”组件均已成功安装。
  • 不要使用虹膜。
  • @Volker 谢谢,我对 go mvc 框架做了一些研究,明白了为什么你不推荐 iris。但目前其他框架无法满足我的要求,例如 gin 框架不支持 i18n 等。
  • @Ace.Yin 在代码中使用hero 包之前,您是否运行过dep ensuredep 删除了不使用的子包,所以如果你没有编写使用 hero 的代码,dep 会认为没有必要。

标签: go dep go-iris


【解决方案1】:

我对 Go 很陌生;但我对另一个库 'https://github.com/jedib0t/go-pretty' 也有类似的问题

$ dep ensure -add github.com/jedib0t/go-pretty
"github.com/jedib0t/go-pretty" is not imported by your project, and has been temporarily added to Gopkg.lock and vendor/.
If you run "dep ensure" again before actually importing it, it will disappear from Gopkg.lock and vendor/.

repo 被克隆到 pkg/dep/sources/https---github.com-jedib0t-go--pretty/ 但是vendor/github.com/jedib0t/go-pretty/ 中没有 Go 代码

我在我的一个源代码文件中添加了一个导入 "github.com/jedib0t/go-pretty" 并运行 dep ensure -v 但是供应商副本没有任何 Go 代码。我删除了文件夹并再次尝试,但结果相同。

为我解决的问题是专门将我想要的包导入到我的代码中,例如:"github.com/jedib0t/go-pretty/table" 并再次运行dep ensure -v。我不确定它为什么会起作用,但也许我的经验可以帮助您或其他人。

【讨论】:

    猜你喜欢
    • 2019-03-05
    • 2018-06-27
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2020-09-14
    • 1970-01-01
    • 2015-07-14
    • 1970-01-01
    相关资源
    最近更新 更多