golang/go · error
object is [%s] expected [%s]
Error message
object is [%s] expected [%s]
What it means
Returned when the object-file ABI header read from an export-data blob does not match the ABI header the running compiler expects (objabi.HeaderString()). It is a hard version gate: the object was produced by a compiler using a different object/ABI format and cannot be consumed.
Source
Thrown at src/cmd/compile/internal/noder/import.go:248
}
// readExportData returns the contents of GC-created unified export data.
func readExportData(f *os.File) (data string, err error) {
r := bio.NewReader(f)
sz, err := exportdata.FindPackageDefinition(r.Reader)
if err != nil {
return
}
end := r.Offset() + int64(sz)
abihdr, _, err := exportdata.ReadObjectHeaders(r.Reader)
if err != nil {
return
}
if expect := objabi.HeaderString(); abihdr != expect {
err = fmt.Errorf("object is [%s] expected [%s]", abihdr, expect)
return
}
_, err = exportdata.ReadExportDataHeader(r.Reader)
if err != nil {
return
}
pos := r.Offset()
// Map export data section (+ end-of-section marker) into memory
// as a single large string. This reduces heap fragmentation and
// allows returning individual substrings very efficiently.
var mapped string
mapped, err = base.MapFile(r.File(), pos, end-pos)
if err != nil {
return
}View on GitHub (pinned to b6b368adc5)
Solutions
- go clean -cache to remove objects with mismatched ABI headers.
- Ensure GOROOT and GOTOOLCHAIN point to the same Go version used to build the dependencies (go version, go env GOROOT GOTOOLCHAIN).
- Rebuild all dependencies from source with the current toolchain (go build -a ./...).
- Remove stale vendored .a files or third-party caches.
Defensive patterns
Strategy: validation
Validate before calling
// Reject build inputs whose object ABI cannot match this compiler.
if !bytes.HasPrefix(objBytes, []byte(objabi.HeaderString())) {
return errors.New("object ABI mismatch; rebuild with current toolchain")
} Prevention
- Build the entire closure with one Go version.
- Pin GOTOOLCHAIN in go.mod for reproducible ABI.
When it happens
Trigger: exportdata.ReadObjectHeaders returns abihdr that differs from objabi.HeaderString(); the comparison at import.go:251 fails and the message reports both the found and expected headers.
Common situations: Mixing object files between Go major versions (e.g. 1.21 objects read by 1.22), a stale build cache from a previous toolchain, or a hand-built -importcfg referencing objects from another Go tree.
Related errors
- import %q: %v
- expected $$ marker, but found %q (recompile package)
- %s: %v
- marshal error %v
- internal error: collision during call site table merge, fn=%
AI-assisted analysis of golang/go@b6b368adc5 (2026-08-12).
Data as JSON: /api/errors/59408f684d763d88.
Report an issue: GitHub.