{"record":{"id":"3c0dbc7cbb083431","repo":"golang/go","slug":"importcfg-d-invalid-packagefile-syntax-is-pack","errorCode":null,"errorMessage":"importcfg:%d: invalid packagefile: syntax is \"packagefile path=filename\": %s","messagePattern":"importcfg:(.+?): invalid packagefile: syntax is \"packagefile path=filename\": (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"src/cmd/go/internal/work/gccgo.go","lineNumber":167,"sourceCode":"\t\tif line == \"\" {\n\t\t\tcontinue\n\t\t}\n\t\tif line == \"\" || strings.HasPrefix(line, \"#\") {\n\t\t\tcontinue\n\t\t}\n\t\tvar verb, args string\n\t\tif i := strings.Index(line, \" \"); i < 0 {\n\t\t\tverb = line\n\t\t} else {\n\t\t\tverb, args = line[:i], strings.TrimSpace(line[i+1:])\n\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 {","sourceCodeStart":149,"sourceCodeEnd":185,"githubUrl":"https://github.com/golang/go/blob/b6b368adc57c96c3151d224d172029f233ead2c3/src/cmd/go/internal/work/gccgo.go#L149-L185","documentation":"The gccgo importcfg parser handles `packagefile path=filename` directives. After splitting args on '=' with strings.Cut, both the path (before) and filename (after) must be non-empty. If either side is empty, this fires with the line number and offending line. Importcfg files are generated by the go command, so a malformed directive usually means a hand-edited or corrupted file.","triggerScenarios":"Fires in the gccgo importcfg reader's `case \"packagefile\"` branch when before == \"\" or after == \"\" after strings.Cut(args, \"=\").","commonSituations":"A hand-edited or truncated importcfg file, a toolchain bug generating malformed output, or a file transfer that corrupted line endings.","solutions":["Do not hand-edit importcfg files; let the go command generate them","Rebuild from scratch: `go clean -cache && go build`","If using gccgo, confirm you are on a compatible gccgo/go version"],"exampleFix":null,"handlingStrategy":"validation","validationCode":"// Validate an importcfg packagefile line before passing it to gccgo\nfunc validPackagefileLine(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":["Never hand-edit importcfg files; regenerate with the go command","Rebuild with `go clean -cache` if importcfg looks corrupt","Keep gccgo and go versions in sync"],"tags":["go-toolchain","gccgo","importcfg","config-parsing"],"backgroundTag":null,"analyzedSha":"b6b368adc57c96c3151d224d172029f233ead2c3","analyzedAt":"2026-08-12T00:22:02.250Z","schemaVersion":2},"datasetVersion":"2026-08-12T12:31:55.035Z"}