Go modules is the newest and very powerful dependency management system for Go. It's used to create, import and manage group of Go packages and ensure that we have reproducible and deterministic builds.
In this episode we are going to see how we can initialise Go modules for a project, how to add, remove, upgrade, downgrade dependencies in Go and what tools the Go toolchain has to make our job easier.
If you want a quick and easy way to see how to work with Go mod you can use go help mod which exposes a list of thorough in-terminal documentation manuals.
How to Initialise Go modules in your project
go mod init example.com/bob/golang-project
How to add a dependency
go get github.com/pkg/errors@v0.9.1
How to upgrade a dependency and all its dependencies recursively
go get -u github.com/pkg/errors@latest
How to remove stale go.sum entries
go mod tidy
How to upgrade all dependencies in a project
go get -u ./...
Go Modules - https://blog.golang.org/using-go-modules
Go Modules Queries - https://golang.org/ref/mod#version-queries
Source Code - https://play.golang.org/p/Nfo7StDWxN1
How to upgrade dependencies in Go - https://golang.cafe/blog/upgrade-dependencies-golang.html
Golang Cafe - https://golang.cafe
Golang Cafe Newsletter - https://golang.cafe/newsletter
Get Hired on Golang Cafe - https://golang.cafe/Golang-Developers
Twitter - https://twitter.com/golangcafe
In this episode we are going to see how we can initialise Go modules for a project, how to add, remove, upgrade, downgrade dependencies in Go and what tools the Go toolchain has to make our job easier.
If you want a quick and easy way to see how to work with Go mod you can use go help mod which exposes a list of thorough in-terminal documentation manuals.
How to Initialise Go modules in your project
go mod init example.com/bob/golang-project
How to add a dependency
go get github.com/pkg/errors@v0.9.1
How to upgrade a dependency and all its dependencies recursively
go get -u github.com/pkg/errors@latest
How to remove stale go.sum entries
go mod tidy
How to upgrade all dependencies in a project
go get -u ./...
Go Modules - https://blog.golang.org/using-go-modules
Go Modules Queries - https://golang.org/ref/mod#version-queries
Source Code - https://play.golang.org/p/Nfo7StDWxN1
How to upgrade dependencies in Go - https://golang.cafe/blog/upgrade-dependencies-golang.html
Golang Cafe - https://golang.cafe
Golang Cafe Newsletter - https://golang.cafe/newsletter
Get Hired on Golang Cafe - https://golang.cafe/Golang-Developers
Twitter - https://twitter.com/golangcafe
- Category
- Depeche Mode
Sign in or sign up to post comments.
Be the first to comment