golang/go · error

${e.Err}

Error message

${e.Err}

What it means

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.

Source

Thrown at src/cmd/go/internal/vet/vet.go:405

				if msg[0] == '[' {
					// []Diagnostic
					var diags []jsonDiagnostic
					if err := json.Unmarshal([]byte(msg), &diags); err != nil {
						return fmt.Errorf("parsing JSON diagnostics: %v", err)
					}
					for _, diag := range diags {
						base.SetExitStatus(1)
						printJSONDiagnostic(analyzer, diag)
					}
				} else {
					// error
					var e jsonError
					if err := json.Unmarshal([]byte(msg), &e); err != nil {
						return fmt.Errorf("parsing JSON error: %v", err)
					}

					base.SetExitStatus(1)
					return errors.New(e.Err)
				}
			}
		}
	}
	return nil
}

var stdouterrMu sync.Mutex // serializes concurrent writes to stdout and stderr

func printJSONDiagnostic(analyzer string, diag jsonDiagnostic) {
	stdouterrMu.Lock()
	defer stdouterrMu.Unlock()

	type posn struct {
		file      string
		line, col int
	}
	parsePosn := func(s string) (_ posn, _ bool) {

View on GitHub (pinned to b6b368adc5)

Solutions

  1. Read e.Err to identify the underlying analysis/build failure.
  2. Re-run without -json to see full output and stack traces.
  3. Fix build/type errors in the target package first.
  4. Update or remove a crashing third-party analyzer.

Example fix

# before
$ go vet -json ./...
# {"Err":"analysis skipped due to errors in package"}

# after (build the package first)
$ go build ./...
$ go vet -json ./...
Defensive patterns

Strategy: try-catch

Validate before calling

// Ensure the package compiles before vetting.
func buildable(pkg string) error {
    return exec.Command("go", "build", pkg).Run()
}

Type guard

// Detect a vet JSON error object.
type jsonError struct{ Err string }

func isVetJSONError(msg []byte) (string, bool) {
    var e jsonError
    if err := json.Unmarshal(msg, &e); err == nil && e.Err != "" { return e.Err, true }
    return "", false
}

Try / catch

if err := vetRun(args); err != nil {
    if msg, ok := extractVetErr(err); ok { /* surface msg, fix build first */ }
}

Prevention

When it happens

Trigger: `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.

Common situations: Package fails to compile so analyzers can't run; a third-party analyzer crashes; type errors.

Related errors


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