LESSON · 1 OF 25

Downloading a dependency with go get

Downloading a dependency with go get

Real programs lean on code other people wrote: a UUID generator, a YAML parser, an AWS client. In Go you pull that code into your module with go get, and the toolchain handles the download for you.

From inside a module (a directory with a go.mod), you name the package by its import path:

sh
go get github.com/google/uuid

The import path doubles as the download location. Go fetches the code, picks a released version, and wires it into your module. That is the whole step - there is no separate install command and no global list of packages to edit by hand.

Run go get <import-path> from inside a module and the dependency is ready to import.

Spin up a fresh environment and practice live.
go · fresh machine · ready in under a minute