Clarification on how moby uses import packages from URL

Hi, I’m trying to understand how import from URL worls in moby/moby repository. The source files under moby/moby github repository have import paths like the following:

import ""
import ""

The 2nd URL doesn’t even exist so I assume it points to… instead?

From what I understand is that whenever we want to import any external package we have to first perform go get <package URL> and then add that URL path under import in the source file. But I’m able to simply clone the moby/moby repo and compile code directly without performing ‘go get…’ prior to it and the compilation just happens fine. I do see a folder in my GOPATH but DO NOT see any child folders like docker/swarmkit/ in it. So, I can’t understand how were the external packages fetched from those URLs? Is it the case that these packages are fetched during the build process and then the local folders are deleted as soon as the build finishes?

The repository uses vendoring, which means that a copy of all the dependencies (or more factually; all the files of the dependencies that are actually used) are included in the repository inside the “vendor” directory;

vendoring allows building the project with a guarantee that you’ll always have the exact same version of the dependencies, and also makes sure that we don’t have to rely on the repositories where those dependencies live (they may be unavailable at times, or bad things could happen, such as someone deleting those repositories, or force-pushing changes)

We vendor those files using a tool named vndr

which uses the vendor.conf file to get the specified version of the dependencies (and where to get them from, in case we (temporarily) use a fork / branch)

if you want to make changes to those files; it’s best to make a fork of the dependency repository that you want to modify, make the changes there, and specify your fork as source for the dependency; that way you don’t have to change the import paths; you can find an example of a dependency that’s currently using a fork at this line;

1 Like

@thaJeztah Thanks you for the detailed explanation. Initially I could not get the changes to reflect in the binary just by updating vendor.conf with the URL of the fork. It’s only when I ran vndr from my root repository on the link you shared that I could solve this issue. I assumed that running vndr command was not required initially.