golang/go · error
expected $$ marker, but found %q (recompile package)
Error message
expected $$ marker, but found %q (recompile package)
What it means
Returned when the mapped export-data buffer does not end with the "\n$$\n" section marker that delimits Go export data. strings.CutSuffix fails, the last up-to-10 bytes are captured, and the message tells the user to recompile the package — the object file is truncated or from an incompatible format.
Source
Thrown at src/cmd/compile/internal/noder/import.go:278
// 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
}
// check for end-of-section marker "\n$$\n" and remove it
const marker = "\n$$\n"
var ok bool
data, ok = strings.CutSuffix(mapped, marker)
if !ok {
cutoff := data // include last 10 bytes in error message
if len(cutoff) >= 10 {
cutoff = cutoff[len(cutoff)-10:]
}
err = fmt.Errorf("expected $$ marker, but found %q (recompile package)", cutoff)
return
}
return
}
// addFingerprint reads the linker fingerprint included at the end of
// the exportdata.
func addFingerprint(path string, data string) error {
var fingerprint goobj.FingerprintType
pos := len(data) - len(fingerprint)
if pos < 0 {
return fmt.Errorf("missing linker fingerprint in exportdata, but found %q", data)
}
buf := []byte(data[pos:])
copy(fingerprint[:], buf)View on GitHub (pinned to b6b368adc5)
Solutions
- Recompile the named package: go build <pkg> or go build -a <pkg>.
- go clean -cache to discard all suspect export data.
- Confirm the toolchain version is consistent across the build (go env GOROOT GOTOOLCHAIN).
- If it persists, capture the object file and report a Go bug with the toolchain versions involved.
Defensive patterns
Strategy: retry
Validate before calling
// Treat missing $$ marker as stale and force a rebuild.
if !strings.HasSuffix(mapped, "\n$$\n") {
os.Remove(objectFile) // force recompile
return rebuild(pkg)
} Prevention
- Avoid interrupting builds mid-write (use go build, not hand-stitched object archives).
- go clean -cache after toolchain upgrades.
When it happens
Trigger: After reading and mapping the export data section, strings.CutSuffix(mapped, "\n$$\n") returns ok=false because the marker is absent; the trailing bytes are shown as evidence.
Common situations: Truncated or partial object file (build killed mid-write), object file from a much older/newer Go that uses a different export-data framing, corrupted build cache entry, or a hand-edited object/archive.
Related errors
AI-assisted analysis of golang/go@b6b368adc5 (2026-08-12).
Data as JSON: /api/errors/27f319e0873c8105.
Report an issue: GitHub.