O'Reilly logo
live online training icon Live Online training

Practical Go Modules

Package management explained by practical examples

Topic: Software Development
Benjamin Muschko

Dependency management is hard in any programming language. Go 1.11 introduced Go modules, the standard package manager for Go projects. With Go modules you can declare and automatically download dependencies on external packages based on semantic versioning—leading to more reliable, reproducible builds of your software.

Expert Benjamin Muschko takes you through the benefits of using Go modules and demonstrates how to effectively use the tooling to tackle challenging dependency management problems you might encounter in your own projects. Along the way, you’ll learn migration strategies for transitioning from another open source package manager.

What you'll learn-and how you can apply it

By the end of this live online course, you’ll understand:

  • The benefits and goals of Go modules
  • How to use the Go modules tooling to effectively manage dependencies

And you’ll be able to:

  • Heavily rely on Go modules for declaring and consuming dependencies
  • Switch to Go modules from a different nonstandard package manager
  • Handle real-world dependency management challenges

This training course is for you because...

  • You’re a Go developer who wants to learn Go modules from the ground up.
  • You’re a Go developer who uses vendoring or other open source package managers and are planning to migrate to Go modules.

Prerequisites

  • A computer with the Go runtime (13.x or higher) and an IDE (optimally GoLand, which will be used for course examples, or VS Code + the Go plug-in) installed
  • A basic understanding of Go
  • Familiarity with package management concepts in any language (knowledge of Go package managers not required)

Recommended preparation:

About your instructor

  • Benjamin Muschko is a software engineer, consultant, and trainer with over 15 years of experience in the industry. An avid open source advocate, he’s passionate about project automation, testing, and continuous delivery. Ben is the author of Gradle in Action (Manning) and is a frequent speaker at conferences.

Schedule

The timeframes are only estimates and may vary according to how the class is progressing

Why modules? (35 minutes)

  • Group discussion: What’s your main learning objective?
  • Presentation: Using GOPATH to resolve packages; using vendoring to resolve packages; What problems can arise?; goals of modules; modules overview, characteristics and resolution workflow

Modules quickstart (35 minutes)

  • Presentation: Initializing modules for a project; recap of semantic versioning; adding a dependency and version selection; listing dependency versions
  • Hands-on exercise: Initialize and use modules for a project
  • Q&A

Break (5 minutes)

Modules day-to-day workflows (40 minutes)

  • Presentation: Dealing with transitive dependencies; verifying dependencies; removing unused dependencies
  • Hands-on exercises: Handle transitive dependencies; verify and tidy dependencies
  • Q&A

Managing modules versions (45 minutes)

  • Presentation: Module versioning rules; declaring a dependency by specific version, wildcard, or commit
  • Hands-on exercises: Use a dependency with multiple major versions; execute module queries
  • Q&A

Break (5 minutes)

Advanced modules techniques (60 minutes)

  • Presentation: Using vendoring with modules; using a custom modules proxy; migration strategies for adopting modules
  • Hands-on exercises: Use vendoring dependencies; use JFrog GoCenter to proxy dependencies; migrate to Go modules

Wrap-up and Q&A (15 minutes)