{"record":{"id":"c340660117915299","repo":"flipped-aurora/gin-vue-admin","slug":"child-plugin-import-cannot-be-blank-or-dot-importe","errorCode":null,"errorMessage":"child plugin import cannot be blank or dot imported","messagePattern":"child plugin import cannot be blank or dot imported","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"server/service/system/auto_code_plugin.go","lineNumber":600,"sourceCode":"\talias := \"subPlugin_\" + childPlugin\n\timported := false\n\tfor _, spec := range astFile.Imports {\n\t\timportPath, err := strconv.Unquote(spec.Path.Value)\n\t\tif err != nil {\n\t\t\treturn err\n\t\t}\n\t\tif importPath != childImportPath {\n\t\t\tcontinue\n\t\t}\n\t\timported = true\n\t\tif spec.Name == nil {\n\t\t\talias = childPlugin\n\t\t} else {\n\t\t\talias = spec.Name.Name\n\t\t}\n\t}\n\tif alias == \"_\" || alias == \".\" {\n\t\treturn errors.New(\"child plugin import cannot be blank or dot imported\")\n\t}\n\tif !imported {\n\t\timportSpec := &goast.ImportSpec{\n\t\t\tName: goast.NewIdent(alias),\n\t\t\tPath: &goast.BasicLit{Kind: token.STRING, Value: strconv.Quote(childImportPath)},\n\t\t}\n\t\tif importDecl := firstImportDeclaration(astFile); importDecl == nil {\n\t\t\tastFile.Decls = append([]goast.Decl{\n\t\t\t\t&goast.GenDecl{Tok: token.IMPORT, Specs: []goast.Spec{importSpec}},\n\t\t\t}, astFile.Decls...)\n\t\t} else {\n\t\t\timportDecl.Specs = append(importDecl.Specs, importSpec)\n\t\t}\n\t}\n\n\tregisterFunc := findPluginRegisterFunction(astFile)\n\tif registerFunc == nil {\n\t\treturn errors.New(\"parent plugin does not implement Register\")","sourceCodeStart":582,"sourceCodeEnd":618,"githubUrl":"https://github.com/flipped-aurora/gin-vue-admin/blob/3136500ef380842b0eb6c4daa87c3f8a47fcf9e0/server/service/system/auto_code_plugin.go#L582-L618","documentation":"When injecting the child plugin import into the parent's plugin.go, the installer computes an import alias (from the spec name or the plugin name). Blank (`_`) and dot (`.`) imports are rejected because the parent's Register function must reference the child package by identifier to call its registration; blank/dot imports would make that reference impossible or ambiguous.","triggerScenarios":"The parent plugin.go already imports the child package with alias `_` or `.` (e.g. someone relied on side-effect-only init registration), and the installer's alias resolution yields `_` or `.` for the child import path.","commonSituations":"Hand-edited parent plugin.go using `import _ \".../child\"` for init-only registration; copied import style from another project; alias accidentally written as underscore when the child plugin name is empty or collides with an existing identifier.","solutions":["Edit the parent plugin.go to import the child package with a named alias (typically the child plugin name), not `_` or `.`.","If the parent used init()-side-effect registration, add an explicit call to the child's Register function inside the parent's Register instead.","Re-run the sub-plugin install after fixing the import so the installer can add/verify the registration call."],"exampleFix":"// before (parent plugin.go)\nimport (\n\t_ \"github.com/org/project/plugin/parent/subPlugin/child\"\n)\n// after\nimport (\n\tchild \"github.com/org/project/plugin/parent/subPlugin/child\"\n)\n\nfunc Register(group *gin.RouterGroup) {\n\tchild.Register(group)\n}","handlingStrategy":"validation","validationCode":"// before install, scan parent plugin.go imports\nif hasBlankOrDotImport(parentPluginGo, childImportPath) {\n  return errors.New(\"replace blank/dot import of child plugin with a named import\")\n}","typeGuard":null,"tryCatchPattern":"if err := installSubPlugin(parent, child); err != nil {\n  if strings.Contains(err.Error(), \"blank or dot imported\") {\n    log.Fatal(\"edit parent plugin.go: use a named import for the child package\")\n  }\n  return err\n}","preventionTips":["Never use `import _` or `import .` for plugin child packages in parent plugin.go.","Rely on explicit Register calls, not init side effects, for plugin wiring.","Code-review any hand edits to generated plugin.go files."],"tags":["plugin-install","go-imports","codegen"],"backgroundTag":"invalid-go-import","analyzedSha":"3136500ef380842b0eb6c4daa87c3f8a47fcf9e0","analyzedAt":"2026-08-31T13:50:02.721Z","schemaVersion":2},"datasetVersion":"2026-08-31T19:17:28.585Z"}