Go get specific version and go get version with Go modules

Go get specific version and go get version with modules: go get with version and go get package version using @v1.2.3, go list for go get version of package, go update package to specific version with @latest and -u=patch, go install specific version for tools; not the same as go version or check go version (toolchain).

Published

Updated

Read time 4 min read

Reviewed byDeepak Prasad

Go get specific version and go get version with Go modules

Readers searching go get version, go get specific version, go get with version, go get package version, go update package to specific version, or go get version of package are almost always using Go modules: dependencies are recorded in go.mod, and go get changes those lines. Queries like go install specific version are about installing a compiled tool at a tag, which uses go install with an @version suffix instead of editing your app’s go.mod. Searches for go version, check go version, or golang get version often mean the compiler/toolchain, not a third-party module; see upgrade Go version for that.

Tested with Go 1.24 on Linux.


Go modules: go get specific version and go get with version

Modern Go (modules on by default since Go 1.16) resolves imports through a module path and a chosen version. The go get command adds or changes a require line in your go.mod file and updates go.sum. For background on local modules and paths, see import local package without GOPATH.

go get version of package: list available versions

Use go list to print known versions before you pin one:

bash
go list -m -versions github.com/gorilla/mux

Example output (trimmed to one line as printed by the tool):

text
github.com/gorilla/mux v1.2.0 v1.3.0 v1.4.0 v1.5.0 v1.6.0 v1.6.1 v1.6.2 v1.7.0 v1.7.1 v1.7.2 v1.7.3 v1.7.4 v1.8.0 v1.8.1

Run the command from a directory inside a module (a tree with a go.mod), or create one with go mod init your/module/path.

go get package version: pin with an @ suffix

The usual go get with version form is the module path plus @ and a version identifier:

bash
go get github.com/gorilla/mux@v1.7.4

After this, go.mod contains a require on v1.7.4 (possibly marked indirect until you import it from code). You can use a semver tag like v1.7.4, a branch name, or a commit hash (the tool records a pseudo-version for non-tag commits).

go update package to specific version

  • Move to a newer tag explicitly: go get example.com/mod@v1.8.1.
  • Allow the resolver to pick the newest tag allowed by the graph: go get example.com/mod@latest.
  • Apply patch updates within the same minor line when possible: go get -u=patch example.com/mod.

If two modules need incompatible major versions of the same path, you may need a replace directive or to upgrade the consumer; go get will report the conflict.

go.mod and reproducibility

After go get specific version, commit both go.mod and go.sum. CI and teammates then resolve the same dependency graph. Use go list -m all to inspect the versions actually selected.


go install specific version (command-line tools)

For binaries (packages with package main under a known path), go install specific version installs a tool without treating it as a library dependency of your current module:

bash
GOBIN=$HOME/go/bin go install golang.org/x/tools/cmd/goimports@v0.24.0

The @v0.24.0 part is required for module mode installs of remote commands (per current go help install behavior). This answers the intent behind go install specific version separately from go get package version for libraries.


gopkg.in (legacy versioned import paths)

Some older projects use gopkg.in/user/pkg.v3 style paths that redirect to tagged GitHub repositories. New code should prefer plain module paths and normal semver tags; treat gopkg.in as compatibility documentation for existing imports. See gopkg.in for the original convention.


Historical tools (dep)

The dep experiment and vendor-only GOPATH workflows are obsolete for new projects. Use modules and go.mod; archived material remains in the dep repository for archaeology only.


Summary

Go get version and go get specific version today mean: run go list -m -versions when you need discovery, then go get module@version to record go get with version in go.mod. go update package to specific version is the same command with a different @ target (@latest, a newer tag, or -u=patch). go install specific version is the right mental model for tools built with go install …@v…, not for ordinary library require lines. go version and check go version refer to the Go toolchain, not golang get version of a dependency—use go.mod and go list -m for those.


References


Frequently Asked Questions

1. How do I go get specific version of a module?

From a module root, run go get example.com/module@v1.2.3 (or another tag, branch, or commit pseudo-version); go updates go.mod and go.sum to record that requirement.

2. How do I see go get version options or go get version of package?

Use go list -m -versions example.com/module to print published semver tags the proxy knows about; then pass the chosen tag to go get with the @suffix.

3. What is the difference between go get with version and go install specific version?

go get records a dependency in the current module’s go.mod; go install example.com/tool@v1.2.3 compiles a command and writes the binary to GOBIN or GOPATH/bin without adding that tool to your library’s go.mod.

4. Does go version or check go version tell me my package versions?

No: go version reports the Go toolchain; dependency versions live in go.mod and go list -m all.

5. How do I go update package to specific version?

Run go get module@version for the exact version, go get module@latest for the newest allowed by your module graph, or go get -u=patch module to move within the same minor line when possible.
Tuan Nguyen

Data Scientist

Proficient in Golang, Python, Java, MongoDB, Selenium, Spring Boot, Kubernetes, Scrapy, API development, Docker, Data Scraping, PrimeFaces, Linux, Data Structures, and Data Mining. With expertise …