golang/go · warning

loading deprecation for %s: %w

Error message

loading deprecation for %s: %w

What it means

Wrapping error from CheckDeprecation: it decorates any non-nil error returned while fetching/parsing the latest version's go.mod to look up a 'Deprecated:' comment. The inner %w carries the real cause (network failure, parse error, 404, checksum failure). CheckDeprecation returns ("", nil) when there is simply no deprecation, so this error specifically means the lookup itself failed.

Source

Thrown at src/cmd/go/internal/modload/modfile.go:306

		if !unicode.IsGraphic(r) && !unicode.IsSpace(r) {
			return "(message omitted: contains non-printable characters)"
		}
	}
	// NOTE: the go.mod parser rejects invalid UTF-8, so we don't check that here.
	return message
}

// CheckDeprecation returns a deprecation message from the go.mod file of the
// latest version of the given module. Deprecation messages are comments
// before or on the same line as the module directives that start with
// "Deprecated:" and run until the end of the paragraph.
//
// CheckDeprecation returns an error if the message can't be loaded.
// CheckDeprecation returns "", nil if there is no deprecation message.
func CheckDeprecation(ld *Loader, ctx context.Context, m module.Version) (deprecation string, err error) {
	defer func() {
		if err != nil {
			err = fmt.Errorf("loading deprecation for %s: %w", m.Path, err)
		}
	}()

	if m.Version == "" {
		// Main module, standard library, or file replacement module.
		// Don't look up deprecation.
		return "", nil
	}
	if repl := Replacement(ld, module.Version{Path: m.Path}); repl.Path != "" {
		// All versions of the module were replaced.
		// We'll look up deprecation separately for the replacement.
		return "", nil
	}

	latest, err := queryLatestVersionIgnoringRetractions(ld, ctx, m.Path)
	if err != nil {
		return "", err
	}

View on GitHub (pinned to b6b368adc5)

Solutions

  1. Check the wrapped error text for the root cause (network, parse, not-found).
  2. If offline, pre-populate the module cache with 'go mod download' or set GOPROXY=off only when the deprecation lookup is not required.
  3. If a replace directive points at a missing local path, correct or remove the replace.
  4. Retry once network/proxy is healthy; treat the error as advisory since it does not block loading.

Example fix

// before
$ go list -m -u all
go: loading deprecation for example.com/pkg: ...network error...

// after
$ GOPROXY=https://proxy.golang.org,direct go list -m -u all
Defensive patterns

Strategy: retry

Validate before calling

// Confirm the latest version is reachable before running deprecation-aware commands:
//   go list -m -versions <module> >/dev/null
// If this fails, the deprecation lookup will also fail; fix proxy/network first.

Try / catch

// Treat deprecation-load errors as advisory, not fatal:
//   out, err := modload.CheckDeprecation(ld, ctx, m)
//   if err != nil {
//       if !errors.Is(err, gover.ErrTooNew) { log.Printf("advisory: %v", err) }
//       out = ""
//   }

Prevention

When it happens

Trigger: Any command that inspects module deprecation ('go list -m -u all', 'go get' advisory output, 'go mod download') when the proxy/module source for the module's latest version is unreachable or its go.mod cannot be parsed.

Common situations: Offline build or unreachable GOPROXY; module deleted from its source; the latest version's go.mod is malformed; a replace directive points at a missing local path; checksum database disagreement.

Related errors


AI-assisted analysis of golang/go@b6b368adc5 (2026-08-12). Data as JSON: /api/errors/c101c1c60e4f9f79. Report an issue: GitHub.