A comprehensive guide to Go modules covering the full dependency management workflow. Topics include creating a module with go mod init, adding sub-packages, using go get to add remote dependencies, referencing specific versions via tags, branches, and commit hashes, and running go mod tidy. Also covers advanced topics: Go workspaces (go work) for multi-module development introduced in Go 1.18, the replace directive for local development and forks, configuring GOPROXY and GOPRIVATE for private module access, and how go get behavior evolved from Go 1.15 through 1.21 with the separation of go get (dependency management) and go install (binary installation).
Table of contents
IntroductionPrerequisitesCreating a New ModuleUnderstanding the go.mod FileAdding Go Code to Your ModuleAdding a Package to Your ModuleAdding a Remote Module as a DependencyUsing a Specific Version of a ModuleWorking with Multiple Modules Using Go WorkspacesUsing the replace DirectiveUnderstanding go get Behavior Across Go VersionsWorking with Private ModulesFAQsConclusionSort: