1. Modules, Packages, and Dependencies

In this chapter, we begin our exploration of Go by looking at how it manages modules, packages, and dependencies. We first look at modules, which are a way to organize a set of packages for distribution under a specific version number for seamless dependency management. We then cover the concept of packages, which is the unit of code that can be imported into other packages. Finally, we look at importing packages from both the standard library and third-party packages.

Modules

A Go module1 is a collection of Go packages2 and their dependencies that can be built, versioned, and managed as a unit. An example of a Go module file layout can be found in Listing 1.1.

1. https://golang.org/ref/mod

2. https://golang.org/ref/spec#Import_declarations ...

Get Go Fundamentals: Gopher Guides now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.