Go classified an import as standard library and searched std for it. When the path is third-party, misspelled, or modules are off, std has nothing to offer and the build stops.
What this error means
A build fails with package X is not in std (GOROOT/src/X). It usually means a third-party path was written as if it were stdlib, or module resolution was disabled so Go fell back to a std-only lookup.
go
main.go:5:2: package github.com/google/uuid is not in std (/usr/local/go/src/github.com/google/uuid)
Diagnose it: module path, proxy, or checksum?
Go module errors name the module but rarely the layer that failed. Separate the three: the module path does not resolve, the proxy cannot serve it, or the checksum database disagrees with what was downloaded.
Terminal
# what Go resolves and from where
go env GOPROXY GOSUMDB GOPRIVATE GOFLAGS
# does the module resolve at all, bypassing the build?
go list -m -versions github.com/org/module
# verify the module cache against go.sum
go mod verify
# private modules must be excluded from proxy and sumdb
go env -w GOPRIVATE=github.com/yourorg/*
Common causes
Third-party import not in go.mod
A non-stdlib package is imported but no require provides it, so Go searches std and fails.
Module mode disabled
With GO111MODULE=off Go resolves only against std and GOPATH, so module dependencies look like missing stdlib.
How to fix it
Add the providing module
Run go mod tidy so the third-party import gets a require directive.
Commit go.mod and go.sum.
Terminal
go mod tidy
go build ./...
Keep module mode on
Ensure GO111MODULE is on (the default) so dependencies resolve via go.mod.
.github/workflows/ci.yml
export GO111MODULE=ongo build ./...
How to prevent it
Run go mod tidy after adding any import.
Leave module mode enabled in CI.
Copy import paths from the package docs to avoid passing them off as stdlib.
Frequently asked questions
What causes Go "package X is not in std"?
There are 2 common causes: third-party import not in go.mod and module mode disabled. A non-stdlib package is imported but no require provides it, so Go searches std and fails.
How do I fix Go "package X is not in std"?
There are 2 fixes depending on which cause you have: add the providing module and keep module mode on. Work through them in order, since the first is the most common.
What does Go "package X is not in std" actually mean?
A build fails with package X is not in std (GOROOT/src/X).
How do I stop Go "package X is not in std" happening again?
Run go mod tidy after adding any import. The prevention section lists 3 changes that keep it from recurring.