Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to get all dependency files for a program

Tags:

go

People also ask

Does go build download dependencies?

Additionally, other commands, such as go build or go test, will add new dependencies automatically based on the stipulated requirements. For example, as earlier illustrated, they can do this to satisfy import requirements, including upgrading go. mod file and installing the new dependencies.

How install all packages to go?

Installing a Package using go getStep 1: Make sure to check whether the Golang is installed on your system by checking the version of Go. Step 2: Set the GOPATH by using the following command. Step 3: Now, set the PATH variable with the help of the following command.

Where are go dependencies installed?

As we have learned in Go installation tutorial, standard Go packages like located inside GOROOT directory (where Go is installed). Other project-level dependencies are stored inside GOPATH.

What does go mod tidy do?

go mod tidy ensures that the go. mod file matches the source code in the module. It adds any missing module requirements necessary to build the current module's packages and dependencies, if there are some not used dependencies go mod tidy will remove those from go.


You can run go get -d ./... from a directory of your project to download all go-gettable dependencies.
Or copy all src subdirectory from your GOPATH to the destination machine.
... is a special pattern, tells to go down recursively.


Try

go list -f '{{ join .Imports "\n" }}'

or

go list -f '{{ join .Deps "\n" }}'

The second will list all subdependencies, the first only the directly imported packages.


Below command works for me it downloads all the dependencies.

go get -u -v -f all

You can use godep save in your local pc where you complete your program. godep save collect all the dependency files for you. When you move to other pc, just copy the Godep folder with your code and it will solve your problems.