Go Packages Managing package dependencies

Help us to keep this website almost Ad Free! It takes only 10 seconds of your time:
> Step 1: Go view our video on YouTube: EF Core Bulk Insert
> Step 2: And Like the video. BONUS: You can also share it!

Example

A common way to download Go dependencies is by using the go get <package> command, which will save the package into the global/shared $GOPATH/src directory. This means that a single version of each package will be linked into each project that includes it as a dependency. This also means that when a new developers deploys your project, they will go get the latest version of each dependency.

However you can keep the build environment consistent, by attaching all the dependencies of a project into the vendor/ directory. Keeping vendored dependencies committed along with your project's repository allows you to do per-project dependency versioning, and provide a consistent environment for your build.

This is what your project's structure will look like:

$GOPATH/src/
├── github.com/username/project/
|   ├── main.go 
|   ├── vendor/
|   |   ├── github.com/pkg/errors
|   |   ├── github.com/gorilla/mux


Got any Go Question?