英文:
How should a glide project import another project with a vendor/ directory?
问题
golang Glide打包工具会自动为项目安装依赖项,但在这样做时,它会从vendor/目录中拉取依赖项,因为许多项目会将供应商依赖项检入。
如何导入包含vendor/目录的Glide依赖项?
目前看来,你可能会遇到以下错误:
./scheduler.go:36: cannot use "github.com/jayunit100/my-project/vendor/github.com/spf13/pflag".CommandLine (type *"github.com/jayunit100/my-project/vendor/a/b/spf13/pflag".FlagSet)
作为类型
*"github.com/jayunit100/my-project/vendor/a/b/vendor/github.com/spf13/pflag".FlagSet
- 正常导入,然后手动删除
vendor/
以避免冗余。 - 正常导入,并使用某种配置技巧来避免
vendor/
依赖项的重复?
英文:
The golang Glide packager automatically will install dependencies for a project, however, in doing so it pulls in dependencies from the vendor/, since many projects check in vendor dependencies.
How should one import a glide dependency which includes a vendor/ directory?
As of now, it appears that you can get errors such as :
./scheduler.go:36: cannot use "github.com/jayunit100/my-project/vendor/github.com/spf13/pflag".CommandLine (type *"github.com/jayunit100/my-project/vendor/a/b/spf13/pflag".FlagSet)
as type
*"github.com/jayunit100/my-project/vendor/a/b/vendor/github.com/spf13/pflag".FlagSet
- import as normal, and then manually delete
vendor/
so there are no redundancies. - import as normal, and use some kind of configuration trick to avoid the
vendor/
dependency duplication?
答案1
得分: 2
我认为这对于使用Glide的人来说是一个很常见的问题。我的团队也遇到了同样的问题,不过我们花了一些时间进行调查,最终发现使用flatten操作可以解决这个问题。
要执行此操作,请在Glide操作中添加-v
标志。
例如:glide up -v
你可以在Glide文档中了解更多信息。
英文:
I think this is quite a common issue for people using glide. My team ran into the same issue and had to investigate for a while but eventually found that using the flatten operation solved this for us.
To do this pass the -v
flag to your glide operations.
e.g. glide up -v
You can read more about it on the glide docs.
答案2
得分: 0
我的当前解决方案是手动删除引入的库中的vendor/目录。
...(更新)glide支持--strip-vendor选项。
英文:
My current solution has been to manually delete vendor/ directories from libraries which are brought in that keep vendor/.
... (Update) glide supports a --strip-vendor option.
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论