Vendoring package which resides in another project's vendor folder

425 Views Asked by At

I'm writing a library package which depends on certain imports but I'm not sure how to handle it correctly.

Let me start with the directory structure:

go/src/github.com/
├── developer A/
│   ├── project 1
│   └── project 2
│   
└── developer B/
    └── project 3
        └── vendor
            └── project 4

Project 1 is a library. It is used in project 2 and gets pulled into 2s vendor folder. Therefore, project 1 should contain all its dependencies such that clients (e.g. project 2) don't need to pull them as well. However, one dependency of project 1 is project 4 which is contained in project 3s vendor folder. It is essential that this dependency is always exactly the version vendored by project 3. Go doesn't allow imports to point to packages inside vendor folders, so I can't import it directly from there. How do I solve this with govendor?

1

There are 1 best solutions below

3
On

Go won't let you reach into another project's vendor directory. It sounds like your intention is to ensure versions. This is what go modules are tasked to do. Take a look at the wiki for more information.