Almost all modern software projects use third-party dependencies to do their job. From version control systems and simple string manipulation to powerful data storage and manipulation, the vast majority of teams can't get their work done without help from outside packages. Often, these packages come from open source as well.
In Go, dependencies are called "packages" or "modules". Packages are the smallest unit of grouped Go code, and modules are the modern unit of package distribution. Both packages and modules have a URL naming scheme - similar, but distinctly different from the Java naming scheme for Jars. In the modern Go ecosystem, there are several methods by which you can fetch packages and modules and include them in your project. In this section we'll look at what both packages and modules are, how to find them and how to include them in your project, and then move onto advanced topics like managing private code, storing your dependencies onsite (instead of in a public, hosted environment), and improving build determinism and speed.
You'll learn how to get started with packages and modules, several methods to manage either dependency type, convert your existing project to modules, and how to manage your dependencies for the duration of your project, no matter how long.
* The Go dependency management ecosystem has evolved significantly in the history of the language. Modules, however, are the de-facto standard and are built into the official Go CLI tooling. If you're starting a new project, I highly recommend using modules, and if you're using another technology for dependencies, I recommend researching whether you can switch to modules. This section covers both scenarios
Table of contents
- Title: Managing Dependencies in Go
- Release date: May 2020
- Publisher(s): Aaron Schlesinger
- ISBN: None
You might also like
Building and leveraging REST APIs with Go
This chapter details the process of writing REST APIs with Go. This chapter starts with basics …
Building full-stack web applications with Go
Building full stack web applications requires drawing on several big technologies, including database access, HTTP routing, …
Hands-On High Performance with Go
Proven methodologies and concurrency techniques that will help you write faster and better code with Go …
The Go Workshop
Cut through the noise and get real results with a step-by-step approach to learning Go programming …