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.
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.
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.
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With