滑行项目应如何导入带有供应商/目录的另一个项目?

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?

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.

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.