Skip to content

Instantly share code, notes, and snippets.

@gnsalok
Created March 31, 2023 13:23
Show Gist options
  • Save gnsalok/f61c2049c64e3ee2dc42a98760a3e8f8 to your computer and use it in GitHub Desktop.
Save gnsalok/f61c2049c64e3ee2dc42a98760a3e8f8 to your computer and use it in GitHub Desktop.
Dependency management in Go
// 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/discordgo@v0.20.3 ; @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