Method to get packages without internet

My VM does not have internet connectivity at the moment, and my development environment is set there. But I can download the package and transfer it to the VM. In which folder should the package be kept? What’s the proper procedure to follow?
PS On searching the internet, I found “/home/ubuntu/go/pkg/mod” has all the packages. But I do not know the step-by-step process to ensure that the package is usable without generating errors.

One option is to use vendoring:

When using modules, the go command typically satisfies dependencies by downloading modules from their sources into the module cache, then loading packages from those downloaded copies. Vendoring may be used to allow interoperation with older versions of Go, or to ensure that all files used for a build are stored in a single file tree.

The go mod vendor command constructs a directory named vendor in the main module’s root directory containing copies of all packages needed to build and test packages in the main module. Packages that are only imported by tests of packages outside the main module are not included. As with go mod tidy and other module commands, build constraints except for ignore are not considered when constructing the vendor directory.

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.