Created
March 31, 2023 13:23
-
-
Save gnsalok/f61c2049c64e3ee2dc42a98760a3e8f8 to your computer and use it in GitHub Desktop.
Dependency management in Go
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Initialise the module | |
$ go mod init <module_name> // ex : github.com/gnsalok/ps-go | |
// If you import any package, you can run the below command to get modules, and it will add a module under the go.mod file | |
$go mod tidy | |
// To verify why other dependencies are in the go.sum file. | |
$ go mod why -m <module_name> // ex : github.com/gorilla/websocket | |
// Get a specific version of a package | |
$ go get <module_name>@version // ex : github.com/bwmarrin/[email protected] ; @latest always pulls the latest | |
// Download vendor dependencies in local | |
$ go mod vendor | |
// remove unused dependencies | |
$ go mod tidy |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment