{"record":{"id":"671983f83f88130e","repo":"golang/go","slug":"importcfg-d-invalid-importmap-syntax-is-import","errorCode":null,"errorMessage":"importcfg:%d: invalid importmap: syntax is \"importmap old=new\": %s","messagePattern":"importcfg:(.+?): invalid importmap: syntax is \"importmap old=new\": (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"src/cmd/go/internal/work/gccgo.go","lineNumber":178,"sourceCode":"\t\t}\n\t\tbefore, after, _ := strings.Cut(args, \"=\")\n\t\tswitch verb {\n\t\tdefault:\n\t\t\tbase.Fatalf(\"importcfg:%d: unknown directive %q\", lineNum, verb)\n\t\tcase \"packagefile\":\n\t\t\tif before == \"\" || after == \"\" {\n\t\t\t\treturn fmt.Errorf(`importcfg:%d: invalid packagefile: syntax is \"packagefile path=filename\": %s`, lineNum, line)\n\t\t\t}\n\t\t\tarchive := gccgoArchive(root, before)\n\t\t\tif err := sh.Mkdir(filepath.Dir(archive)); err != nil {\n\t\t\t\treturn err\n\t\t\t}\n\t\t\tif err := sh.Symlink(after, archive); err != nil {\n\t\t\t\treturn err\n\t\t\t}\n\t\tcase \"importmap\":\n\t\t\tif before == \"\" || after == \"\" {\n\t\t\t\treturn fmt.Errorf(`importcfg:%d: invalid importmap: syntax is \"importmap old=new\": %s`, lineNum, line)\n\t\t\t}\n\t\t\tbeforeA := gccgoArchive(root, before)\n\t\t\tafterA := gccgoArchive(root, after)\n\t\t\tif err := sh.Mkdir(filepath.Dir(beforeA)); err != nil {\n\t\t\t\treturn err\n\t\t\t}\n\t\t\tif err := sh.Mkdir(filepath.Dir(afterA)); err != nil {\n\t\t\t\treturn err\n\t\t\t}\n\t\t\tif err := sh.Symlink(afterA, beforeA); err != nil {\n\t\t\t\treturn err\n\t\t\t}\n\t\tcase \"packageshlib\":\n\t\t\treturn fmt.Errorf(\"gccgo -importcfg does not support shared libraries\")\n\t\t}\n\t}\n\treturn nil\n}","sourceCodeStart":160,"sourceCodeEnd":196,"githubUrl":"https://github.com/golang/go/blob/b6b368adc57c96c3151d224d172029f233ead2c3/src/cmd/go/internal/work/gccgo.go#L160-L196","documentation":"The gccgo importcfg parser handles `importmap old=new` directives. Both sides of the '=' must be non-empty after strings.Cut. If either is empty, this fires with the line number and offending line. Same validation shape as 1196 but for import-remapping directives used to alias import paths.","triggerScenarios":"Fires in the gccgo importcfg reader's `case \"importmap\"` branch when before == \"\" or after == \"\" after strings.Cut(args, \"=\").","commonSituations":"A corrupted or hand-edited importcfg file, or a toolchain bug emitting a malformed importmap line.","solutions":["Do not hand-edit importcfg files; let the go command generate them","Rebuild from scratch: `go clean -cache && go build`","Confirm a compatible gccgo/go version"],"exampleFix":null,"handlingStrategy":"validation","validationCode":"// Validate an importcfg importmap line before passing it to gccgo\nfunc validImportmapLine(line string) bool {\n    _, after, ok := strings.Cut(line, \" \")\n    if !ok { return false }\n    before, after, ok := strings.Cut(after, \"=\")\n    return ok && before != \"\" && after != \"\"\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Do not hand-edit importcfg files","Regenerate importcfg via the go command after toolchain upgrades","Validate line syntax if you generate importcfg programmatically"],"tags":["go-toolchain","gccgo","importcfg","config-parsing"],"analyzedSha":"b6b368adc57c96c3151d224d172029f233ead2c3","analyzedAt":"2026-08-12T00:22:02.250Z","schemaVersion":2},"datasetVersion":"2026-08-12T12:17:08.281Z"}