{"record":{"id":"7e56612aac285fd9","repo":"golang/go","slug":"e-err","errorCode":null,"errorMessage":"${e.Err}","messagePattern":"\\$\\{e\\.Err\\}","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"src/cmd/go/internal/vet/vet.go","lineNumber":405,"sourceCode":"\t\t\t\tif msg[0] == '[' {\n\t\t\t\t\t// []Diagnostic\n\t\t\t\t\tvar diags []jsonDiagnostic\n\t\t\t\t\tif err := json.Unmarshal([]byte(msg), &diags); err != nil {\n\t\t\t\t\t\treturn fmt.Errorf(\"parsing JSON diagnostics: %v\", err)\n\t\t\t\t\t}\n\t\t\t\t\tfor _, diag := range diags {\n\t\t\t\t\t\tbase.SetExitStatus(1)\n\t\t\t\t\t\tprintJSONDiagnostic(analyzer, diag)\n\t\t\t\t\t}\n\t\t\t\t} else {\n\t\t\t\t\t// error\n\t\t\t\t\tvar e jsonError\n\t\t\t\t\tif err := json.Unmarshal([]byte(msg), &e); err != nil {\n\t\t\t\t\t\treturn fmt.Errorf(\"parsing JSON error: %v\", err)\n\t\t\t\t\t}\n\n\t\t\t\t\tbase.SetExitStatus(1)\n\t\t\t\t\treturn errors.New(e.Err)\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\treturn nil\n}\n\nvar stdouterrMu sync.Mutex // serializes concurrent writes to stdout and stderr\n\nfunc printJSONDiagnostic(analyzer string, diag jsonDiagnostic) {\n\tstdouterrMu.Lock()\n\tdefer stdouterrMu.Unlock()\n\n\ttype posn struct {\n\t\tfile      string\n\t\tline, col int\n\t}\n\tparsePosn := func(s string) (_ posn, _ bool) {","sourceCodeStart":387,"sourceCodeEnd":423,"githubUrl":"https://github.com/golang/go/blob/b6b368adc57c96c3151d224d172029f233ead2c3/src/cmd/go/internal/vet/vet.go#L387-L423","documentation":"The vet command reads JSON output from the analysis driver line by line. If a line is a JSON object with an \"Err\" field (a jsonError), it is not a diagnostic but a top-level analysis failure; vet sets exit status 1 and returns errors.New(e.Err), surfacing the driver's message verbatim.","triggerScenarios":"`go vet -json` (or programmatic vet) where the analysis driver emits a top-level error object — typically an analyzer panic, a build error in the package, or a driver configuration problem.","commonSituations":"Package fails to compile so analyzers can't run; a third-party analyzer crashes; type errors.","solutions":["Read e.Err to identify the underlying analysis/build failure.","Re-run without -json to see full output and stack traces.","Fix build/type errors in the target package first.","Update or remove a crashing third-party analyzer."],"exampleFix":"# before\n$ go vet -json ./...\n# {\"Err\":\"analysis skipped due to errors in package\"}\n\n# after (build the package first)\n$ go build ./...\n$ go vet -json ./...","handlingStrategy":"try-catch","validationCode":"// Ensure the package compiles before vetting.\nfunc buildable(pkg string) error {\n    return exec.Command(\"go\", \"build\", pkg).Run()\n}","typeGuard":"// Detect a vet JSON error object.\ntype jsonError struct{ Err string }\n\nfunc isVetJSONError(msg []byte) (string, bool) {\n    var e jsonError\n    if err := json.Unmarshal(msg, &e); err == nil && e.Err != \"\" { return e.Err, true }\n    return \"\", false\n}","tryCatchPattern":"if err := vetRun(args); err != nil {\n    if msg, ok := extractVetErr(err); ok { /* surface msg, fix build first */ }\n}","preventionTips":["Run `go build ./...` before `go vet` so analyzers have valid packages.","Keep third-party analyzers current.","Inspect raw JSON output (-json) when a vet run fails opaquely."],"tags":["vet","json","analysis","build-errors"],"analyzedSha":"b6b368adc57c96c3151d224d172029f233ead2c3","analyzedAt":"2026-08-12T00:22:02.250Z","schemaVersion":2},"datasetVersion":"2026-08-12T06:17:24.410Z"}