{"record":{"id":"6fd20e9b07363dc0","repo":"golang/go","slug":"import-q-v","errorCode":null,"errorMessage":"import %q: %v","messagePattern":"import %q: (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"src/cmd/compile/internal/importer/gcimporter.go","lineNumber":78,"sourceCode":"\t\t// open file\n\t\tf, err := os.Open(filename)\n\t\tif err != nil {\n\t\t\treturn nil, err\n\t\t}\n\t\tdefer func() {\n\t\t\tif err != nil {\n\t\t\t\t// add file name to error\n\t\t\t\terr = fmt.Errorf(\"%s: %v\", filename, err)\n\t\t\t}\n\t\t}()\n\t\trc = f\n\t}\n\tdefer rc.Close()\n\n\tbuf := bufio.NewReader(rc)\n\tdata, err := exportdata.ReadUnified(buf)\n\tif err != nil {\n\t\terr = fmt.Errorf(\"import %q: %v\", path, err)\n\t\treturn\n\t}\n\ts := string(data)\n\n\tinput := pkgbits.NewPkgDecoder(id, s)\n\tpkg = ReadPackage(nil, packages, input)\n\n\treturn\n}\n","sourceCodeStart":60,"sourceCodeEnd":88,"githubUrl":"https://github.com/golang/go/blob/b6b368adc57c96c3151d224d172029f233ead2c3/src/cmd/compile/internal/importer/gcimporter.go#L60-L88","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","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."],"exampleFix":null,"handlingStrategy":"validation","validationCode":"// Verify the toolchain that produced the object file matches the running one.\n// (Objects embed the Go version; mismatch implies incompatible export data.)\nif goVersionProducingObject != runtime.Version() {\n    return errors.New(\"rebuild dependency with current toolchain\")\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["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."],"tags":["go-compiler","importer","export-data","toolchain-mismatch"],"analyzedSha":"b6b368adc57c96c3151d224d172029f233ead2c3","analyzedAt":"2026-08-12T00:22:02.250Z","schemaVersion":2},"datasetVersion":"2026-08-12T06:17:24.410Z"}