Skip to content
Latchkey

staticcheck SA1019 "is deprecated" - Fix in CI

staticcheck SA1019 fires when code calls something annotated with a Deprecated comment. The check exists so deprecated APIs get migrated before they are removed in a future release.

What this error means

staticcheck (often via golangci-lint) fails with SA1019: X is deprecated. A deprecated function, field, or package is still in use.

go
main.go:9:14: SA1019: rand.Seed has been deprecated since Go 1.20 (staticcheck)

Diagnose it: toolchain, tags, or platform?

Go build failures that only appear in CI usually come from a different toolchain version, different build tags, or cross-compilation defaults that differ from your machine.

Terminal
go version
go env GOOS GOARCH CGO_ENABLED GOFLAGS GOTOOLCHAIN

# build exactly what CI builds, verbosely
go build -v ./... 2>&1 | tail -40

# CGO is the usual difference: on by default locally, often off in a slim CI image
CGO_ENABLED=0 go build ./...

Common causes

Calling a deprecated API

The code uses a symbol whose doc comment marks it Deprecated, which SA1019 flags.

Dependency upgrade deprecated an API

A bumped library deprecated a function the code still calls, so the check newly fires.

How to fix it

Migrate to the replacement

  1. Read the deprecation note and switch to the recommended API.
Go
r := rand.New(rand.NewSource(time.Now().UnixNano()))

Suppress narrowly if migration is blocked

  1. Add a scoped nolint with a reason on the exact line, not globally.
Go
x := old.API() //nolint:staticcheck // SA1019: pending upstream replacement

How to prevent it

  • Migrate off deprecated APIs as soon as they are flagged.
  • Read deprecation notes when bumping dependencies.
  • Suppress narrowly with a reason rather than disabling SA1019 globally.

Frequently asked questions

What causes staticcheck SA1019 "is deprecated"?
There are 2 common causes: calling a deprecated api and dependency upgrade deprecated an api. The code uses a symbol whose doc comment marks it Deprecated, which SA1019 flags.
How do I fix staticcheck SA1019 "is deprecated"?
There are 2 fixes depending on which cause you have: migrate to the replacement and suppress narrowly if migration is blocked. Work through them in order, since the first is the most common.
What does staticcheck SA1019 "is deprecated" actually mean?
staticcheck (often via golangci-lint) fails with SA1019: X is deprecated.
How do I stop staticcheck SA1019 "is deprecated" happening again?
Migrate off deprecated APIs as soon as they are flagged. The prevention section lists 3 changes that keep it from recurring.

Related guides

References

Not every red build is your code. Latchkey repairs the ones that are not, on the runner. Start free → 30-day trial · No credit card