golang/go · error
import %q: %v
Error message
import %q: %v
What it means
Thrown by gcimporter when exportdata.ReadUnified cannot parse the export data read from the object file. The error is wrapped with the import path so the message reads "import \"<path>\": <parse error>". It signals the export-data bytes are malformed, truncated, or in an unexpected format for this compiler version.
Source
Thrown at src/cmd/compile/internal/importer/gcimporter.go:78
// open file
f, err := os.Open(filename)
if err != nil {
return nil, err
}
defer func() {
if err != nil {
// add file name to error
err = fmt.Errorf("%s: %v", filename, err)
}
}()
rc = f
}
defer rc.Close()
buf := bufio.NewReader(rc)
data, err := exportdata.ReadUnified(buf)
if err != nil {
err = fmt.Errorf("import %q: %v", path, err)
return
}
s := string(data)
input := pkgbits.NewPkgDecoder(id, s)
pkg = ReadPackage(nil, packages, input)
return
}
View on GitHub (pinned to b6b368adc5)
Solutions
- go clean -cache to wipe stale export data and rebuild.
- Ensure the whole module (including all deps) is built with the same Go toolchain version (go version on each binary).
- Remove hand-edited -importcfg / -importmap flags and let go build compute them.
- If reproducible, file a Go issue with the object file and both toolchain versions.
Defensive patterns
Strategy: validation
Validate before calling
// Verify the toolchain that produced the object file matches the running one.
// (Objects embed the Go version; mismatch implies incompatible export data.)
if goVersionProducingObject != runtime.Version() {
return errors.New("rebuild dependency with current toolchain")
} Prevention
- Build the whole dependency closure with one Go version.
- Avoid mixing -gcflags/-asmflags that change object layout.
- Keep the build cache clean across toolchain upgrades.
When it happens
Trigger: bufio.Reader wrapping the object file is handed to exportdata.ReadUnified; if that returns an error (unrecognized archive tag, truncated unified section, wrong magic), the importer wraps it with the import path and returns it from Import.
Common situations: Cross-toolchain builds where one Go version wrote export data and a different version reads it; object files left over from an aborted build; partial git checkout of the Go tree; mixed -gcflags/-asmflags producing incompatible object files.
Related errors
- expected $$ marker, but found %q (recompile package)
- %s: %v
- object is [%s] expected [%s]
- 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/6fd20e9b07363dc0.
Report an issue: GitHub.