The documentation says,
The go mod vendor command constructs a directory named vendor in the main module's root directory that contains copies of all packages needed to support builds and tests of packages in the main module. Packages that are only imported by tests of packages outside the main module are not included.
golangbyexample says:
You can also check in the vendor directory to your VCS (Version Control System). This becomes useful in sense that none of the dependency needs to be downloaded at run time as it is already present in the vendor folder checked into VCS
I think modules (go.mod
,go.sum
) take care of the versioning. I also think that dependencies are only downloaded when I run the program for the first time.
So, how is the command go mod vendor
useful? What is its purpose or use case?
go/pkg/mod/cache/download/github.com
andgo/pkg/mod/github.com
. To run it the second time, I do not need the internet connection anyways. So, how can "build the project without needing internet access" be the purpose of this command. What am I missing? – Plaice