People searching for go list installed packages, golang list installed packages, go list installed, go list global packages, go list packages, list go packages, or go packages list usually want one of three things: import paths for the standard library, packages (or modules) tied to a project on disk, or the location of code and binaries the toolchain downloaded or built. The go list command is the supported way to answer the first two; paths come from go env. For how GOPATH and GOROOT differ, see GOPATH vs GOROOT and Go environment variables.
Tested with Go 1.24 on Linux.
go list command: packages and modules
go list prints one line per package (or per module when you pass -m) for the patterns you name. Official reference: List packages or modules.
Standard library: go list std
To list standard-library import paths:
go list stdarchive/tar
archive/zip
bufio
bytes
cmp
compress/bzip2
compress/flate
compress/gzip
compress/lzw
compress/zlibPackages in the current module: go list ./... and go list all
From the root of a module (where go.mod lives), go list ./... lists every package under that tree. go list all lists every package in the transitive closure for the main module (standard library plus dependencies), which is a long list—filter with tools like grep when you only need a prefix.
cd /path/to/your/module
go list ./...
go list all | headModules (dependency graph): go list -m all
go list -m switches listing to modules instead of packages. go list -m all prints the module versions your main module can build against (your module plus required modules). Run it from inside your project with a go.mod; it is not a “global installed packages” query for the whole machine.
cd /path/to/your/module
go list -m allExample output shape:
example.com/demo
github.com/google/uuid v1.6.0JSON for modules (trimmed):
go list -m -json all{
"Path": "example.com/demo",
"Main": true,
"Dir": "/path/to/your/module",
"GoMod": "/path/to/your/module/go.mod",
"GoVersion": "1.22"
}
{
"Path": "github.com/google/uuid",
"Version": "v1.6.0",
"Time": "2024-01-23T18:54:04Z",
"Dir": "/home/you/go/pkg/mod/github.com/google/uuid@v1.6.0",
"GoMod": "/home/you/go/pkg/mod/cache/download/github.com/google/uuid/@v/v1.6.0.mod",
"Sum": "h1:NIvaJDMOsjHA8n1jAhLSgzrAzy1Hgr+hNrb57e+94F0=",
"GoModSum": "h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo="
}Custom columns: -f
-f uses Go’s text/template syntax on the package or module struct. For a single package, show where sources live:
go list -f '{{.ImportPath}} -> {{.Dir}}' encoding/jsonencoding/json -> /usr/local/go/src/encoding/jsonInside a module, the same template on a dependency shows the module cache directory:
go list -f '{{.ImportPath}} -> {{.Dir}}' github.com/google/uuidgithub.com/google/uuid -> /home/you/go/pkg/mod/github.com/google/uuid@v1.6.0The -e flag relaxes errors for missing or invalid packages so listing can continue; it does not mean “exportable only.” Use it when you intentionally want partial results from a messy pattern set.
Where go packages and binaries live
Run:
go env GOROOT GOMODCACHE GOPATHTypical roles:
GOROOT— Go toolchain and standard library sources (go list stdpaths resolve under here).GOMODCACHE— Downloaded module contents (versioned directories under…/pkg/mod/...by layout convention).GOPATH— Still defines default locations:GOPATH/binfor installed commands whenGOBINis empty, and often hostspkg/modunder the same tree unlessGOMODCACHEoverrides it.
There is no single global “registry” directory that enumerates every package ever used on the machine; the module cache grows as you build different projects.
Commands installed with go install
go install builds a command and places the binary in GOBIN if that variable is non-empty, otherwise in $(go env GOPATH)/bin. To see what you have on PATH, list that directory (for example ls "$(go env GOPATH)/bin").
To see build metadata embedded in any Go-built executable:
go version -m "$(command -v gofmt)"/usr/local/go/bin/gofmt: go1.24.4
path cmd/gofmt
build -buildmode=exe
build -compiler=gcThe first line is the go version that built the binary; path names the command module. Binaries you built with go install from the module proxy often add mod and dep lines as well—run the same command on a file under $(go env GOPATH)/bin.
Summary
The go list command answers “which import paths or modules exist for this pattern,” not “everything ever installed system-wide.” Use go list std for the standard library, go list ./... and go list all for packages in a module context, and go list -m all for module versions in the current main module. On disk, standard library code sits under GOROOT, cached modules under GOMODCACHE, and go install binaries under GOBIN or GOPATH/bin. Pair go list -f or -json when you need directories and versions in scripts.
References
- List packages or modules (
go list) - How to list installed go packages (Stack Overflow)
- GOPATH vs GOROOT
- Go environment variables

