golang/go · error

internal error marshaling vet config: %v

Error message

internal error marshaling vet config: %v

What it means

Before writing vet.cfg for the vet tool, the go command serializes the vetConfig struct with json.MarshalIndent. If this fails, the error is explicitly labeled "internal error" because vetConfig holds only JSON-safe types (strings, maps, slices). It is a defensive guard for a condition that should be unreachable in practice.

Source

Thrown at src/cmd/go/internal/work/exec.go:1718

			}
			defer f.Close() // ignore error (can't fail)
			stdout = f
		}

		// Cache hit: commit transaction.
		a.built = vetxFile
		a.FixArchive = fixArchive
		if err := VetHandleStdout(stdout); err != nil {
			return err // internal error (don't fall through to cachemiss)
		}

		return nil
	}
cachemiss:

	js, err := json.MarshalIndent(vcfg, "", "\t")
	if err != nil {
		return fmt.Errorf("internal error marshaling vet config: %v", err)
	}
	js = append(js, '\n')
	if err := sh.writeFile(a.Objdir+"vet.cfg", js); err != nil {
		return err
	}

	// TODO(rsc): Why do we pass $GCCGO to go vet?
	env := b.cCompilerEnv()
	if cfg.BuildToolchainName == "gccgo" {
		env = append(env, "GCCGO="+BuildToolchain.compiler())
	}

	p := a.Package
	tool := VetTool
	if tool == "" {
		panic("VetTool unset")
	}

View on GitHub (pinned to b6b368adc5)

Solutions

  1. Reinstall the Go toolchain
  2. Report as a Go bug with the package and vet flags
Defensive patterns

Strategy: validation

Prevention

When it happens

Trigger: Fires at the cachemiss label of the vet action builder when json.MarshalIndent(vcfg, "", "\t") returns a non-nil error.

Common situations: Should not occur; a corrupted Go installation or memory fault would be the only realistic cause.

Related errors


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