{"record":{"id":"c101c1c60e4f9f79","repo":"golang/go","slug":"loading-deprecation-for-s-w","errorCode":null,"errorMessage":"loading deprecation for %s: %w","messagePattern":"loading deprecation for (.+?): %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"warning","filePath":"src/cmd/go/internal/modload/modfile.go","lineNumber":306,"sourceCode":"\t\tif !unicode.IsGraphic(r) && !unicode.IsSpace(r) {\n\t\t\treturn \"(message omitted: contains non-printable characters)\"\n\t\t}\n\t}\n\t// NOTE: the go.mod parser rejects invalid UTF-8, so we don't check that here.\n\treturn message\n}\n\n// CheckDeprecation returns a deprecation message from the go.mod file of the\n// latest version of the given module. Deprecation messages are comments\n// before or on the same line as the module directives that start with\n// \"Deprecated:\" and run until the end of the paragraph.\n//\n// CheckDeprecation returns an error if the message can't be loaded.\n// CheckDeprecation returns \"\", nil if there is no deprecation message.\nfunc CheckDeprecation(ld *Loader, ctx context.Context, m module.Version) (deprecation string, err error) {\n\tdefer func() {\n\t\tif err != nil {\n\t\t\terr = fmt.Errorf(\"loading deprecation for %s: %w\", m.Path, err)\n\t\t}\n\t}()\n\n\tif m.Version == \"\" {\n\t\t// Main module, standard library, or file replacement module.\n\t\t// Don't look up deprecation.\n\t\treturn \"\", nil\n\t}\n\tif repl := Replacement(ld, module.Version{Path: m.Path}); repl.Path != \"\" {\n\t\t// All versions of the module were replaced.\n\t\t// We'll look up deprecation separately for the replacement.\n\t\treturn \"\", nil\n\t}\n\n\tlatest, err := queryLatestVersionIgnoringRetractions(ld, ctx, m.Path)\n\tif err != nil {\n\t\treturn \"\", err\n\t}","sourceCodeStart":288,"sourceCodeEnd":324,"githubUrl":"https://github.com/golang/go/blob/b6b368adc57c96c3151d224d172029f233ead2c3/src/cmd/go/internal/modload/modfile.go#L288-L324","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","solutions":["Check the wrapped error text for the root cause (network, parse, not-found).","If offline, pre-populate the module cache with 'go mod download' or set GOPROXY=off only when the deprecation lookup is not required.","If a replace directive points at a missing local path, correct or remove the replace.","Retry once network/proxy is healthy; treat the error as advisory since it does not block loading."],"exampleFix":"// before\n$ go list -m -u all\ngo: loading deprecation for example.com/pkg: ...network error...\n\n// after\n$ GOPROXY=https://proxy.golang.org,direct go list -m -u all","handlingStrategy":"retry","validationCode":"// Confirm the latest version is reachable before running deprecation-aware commands:\n//   go list -m -versions <module> >/dev/null\n// If this fails, the deprecation lookup will also fail; fix proxy/network first.","typeGuard":null,"tryCatchPattern":"// Treat deprecation-load errors as advisory, not fatal:\n//   out, err := modload.CheckDeprecation(ld, ctx, m)\n//   if err != nil {\n//       if !errors.Is(err, gover.ErrTooNew) { log.Printf(\"advisory: %v\", err) }\n//       out = \"\"\n//   }","preventionTips":["Keep GOPROXY pointing at a reachable, mirrored proxy (e.g. https://proxy.golang.org,direct).","Cache 'go mod download' outputs so offline runs already have the latest go.mod.","Treat CheckDeprecation errors as warnings in tooling; they are advisory, not load-blocking."],"tags":["go-modules","deprecation","network","proxy","go-modfile"],"analyzedSha":"b6b368adc57c96c3151d224d172029f233ead2c3","analyzedAt":"2026-08-12T00:22:02.250Z","schemaVersion":2},"datasetVersion":"2026-08-12T06:17:24.410Z"}