{"record":{"id":"02e9fc1e8fe3598e","repo":"golang/go","slug":"s-v","errorCode":null,"errorMessage":"%s: %v","messagePattern":"%s: %v","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"src/cmd/compile/internal/importer/gcimporter.go","lineNumber":68,"sourceCode":"\t\t\t\treturn types2.Unsafe, nil\n\t\t\t}\n\t\t\treturn nil, err\n\t\t}\n\n\t\t// no need to re-import if the package was imported completely before\n\t\tif pkg = packages[id]; pkg != nil && pkg.Complete() {\n\t\t\treturn\n\t\t}\n\n\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","sourceCodeStart":50,"sourceCodeEnd":86,"githubUrl":"https://github.com/golang/go/blob/b6b368adc57c96c3151d224d172029f233ead2c3/src/cmd/compile/internal/importer/gcimporter.go#L50-L86","documentation":"Thrown by the Go compiler's gcimporter when opening an export-data file (object/archive) fails. A deferred closure prepends the file name to whatever I/O error os.Open returned, so the message reads as \"<filename>: <underlying error>\". It is purely an annotation wrapper; the real cause is whatever os.Open reported (missing file, permission denied, not an archive).","triggerScenarios":"The compiler (or go/types importer) tries to read an object file's export data via gcimporter and os.Open(filename) returns a non-nil error; the deferred wrapper at gcimporter.go:68 then formats it. Triggers when the resolved filename does not exist, is unreadable, or points to a directory.","commonSituations":"Stale or partially-cleaned build cache (go clean -cache mid-build), corrupted GOROOT/GOPATH, switching Go toolchain versions without rebuilding dependencies, missing vendored object file, or a broken GOFLAGS/-importcfg pointing at a removed file.","solutions":["Run go clean -cache then rebuild to regenerate all object/export-data files.","Verify the path in the error message exists and is readable (ls -l <filename>).","Reinstall or rebuild the offending dependency with go install <pkg>@latest or go build ./... from a clean tree.","Check that GOROOT/GOTOOLCHAIN match the go version in use (go env GOROOT GOTOOLCHAIN)."],"exampleFix":null,"handlingStrategy":"validation","validationCode":"// Before invoking the importer, ensure the resolved object file exists and is readable.\nimport \"os\"\nif info, err := os.Stat(filename); err != nil || info.IsDir() {\n    return fmt.Errorf(\"export data unavailable: %s\", filename)\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Treat the build cache as ephemeral: go clean -cache whenever you switch toolchains.","Pin GOFLAGS/GOTOOLCHAIN in CI to avoid surprising path resolutions.","Validate -importcfg inputs reference existing files before launching the compiler."],"tags":["go-compiler","importer","io","build-cache"],"analyzedSha":"b6b368adc57c96c3151d224d172029f233ead2c3","analyzedAt":"2026-08-12T00:22:02.250Z","schemaVersion":2},"datasetVersion":"2026-08-12T06:17:24.410Z"}