Lesson 22 of 60
GoDependency Management with Go Modules
15 minutes
Course progress37%
Go Modules Refresher
This lesson explains the main concept clearly with beginner-friendly examples and background so you can learn why the code works.
A module is a collection of related Go packages versioned together.
Initialising a module
$ mkdir cli && cd cli
$ go mod init github.com/yourname/cli
Adding a dependency
$ go get github.com/spf13/cobra@v1.7.0
The go.mod file now contains:
module github.com/yourname/cli
require github.com/spf13/cobra v1