{"record":{"id":"b51011b077270e94","repo":"flipped-aurora/gin-vue-admin","slug":"plugin-plugin-s-plugin-go","errorCode":null,"errorMessage":"plugin结构异常,缺少plugin/%s/plugin.go","messagePattern":"plugin结构异常,缺少plugin/(.+?)/plugin\\.go","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"server/service/system/auto_code_template.go","lineNumber":56,"sourceCode":"\t\t_, err = os.Stat(apiEnter)\n\t\tif err != nil {\n\t\t\treturn fmt.Errorf(\"package结构异常,缺少api/v1/%s/enter.go\", Pkg)\n\t\t}\n\t\tserviceEnter := filepath.Join(global.GVA_CONFIG.AutoCode.Root, global.GVA_CONFIG.AutoCode.Server, \"service\", Pkg, \"enter.go\")\n\t\t_, err = os.Stat(serviceEnter)\n\t\tif err != nil {\n\t\t\treturn fmt.Errorf(\"package结构异常,缺少service/%s/enter.go\", Pkg)\n\t\t}\n\t\trouterEnter := filepath.Join(global.GVA_CONFIG.AutoCode.Root, global.GVA_CONFIG.AutoCode.Server, \"router\", Pkg, \"enter.go\")\n\t\t_, err = os.Stat(routerEnter)\n\t\tif err != nil {\n\t\t\treturn fmt.Errorf(\"package结构异常,缺少router/%s/enter.go\", Pkg)\n\t\t}\n\tcase \"plugin\":\n\t\tpluginEnter := filepath.Join(global.GVA_CONFIG.AutoCode.Root, global.GVA_CONFIG.AutoCode.Server, \"plugin\", Pkg, \"plugin.go\")\n\t\t_, err = os.Stat(pluginEnter)\n\t\tif err != nil {\n\t\t\treturn fmt.Errorf(\"plugin结构异常,缺少plugin/%s/plugin.go\", Pkg)\n\t\t}\n\t}\n\treturn nil\n}\n\n// Create 创建生成自动化代码\nfunc (s *autoCodeTemplate) Create(ctx context.Context, info request.AutoCode) error {\n\tautoCodeCreateMu.Lock()\n\tdefer autoCodeCreateMu.Unlock()\n\n\t// Frontend files are published last, but their Vite refresh may still cancel\n\t// the HTTP request before the handler returns. The accepted create task must finish.\n\tcreateCtx := autoCodeCreateContext(ctx)\n\tvar autoPkg model.SysAutoCodePackage\n\terr := global.GVA_DB.WithContext(createCtx).Where(\"package_name = ?\", info.Package).First(&autoPkg).Error\n\tif err != nil {\n\t\treturn errors.Wrap(err, \"查询包失败!\")\n\t}","sourceCodeStart":38,"sourceCodeEnd":74,"githubUrl":"https://github.com/flipped-aurora/gin-vue-admin/blob/3136500ef380842b0eb6c4daa87c3f8a47fcf9e0/server/service/system/auto_code_template.go#L38-L74","documentation":"checkPackage validates plugin-type generation: the target plugin must already have plugin/<Pkg>/plugin.go (the plugin entry aggregating its routes/apis) under the configured server root. If missing, Create aborts with this error. It prevents generating code into a plugin that was never initialized.","triggerScenarios":"autoCodeTemplate.Create with template=\"plugin\" and a Pkg whose server/plugin/<Pkg>/plugin.go does not exist — plugin directory never created or named differently.","commonSituations":"Typo in plugin name in the generator form; plugin created only in web/src/plugin but not server/plugin; plugin scaffold deleted; autoCode.root/server config pointing at a different checkout.","solutions":["Initialize the plugin skeleton so server/plugin/<Pkg>/plugin.go exists (public Plugin variable, Router registration) and register it in plugin/initialize.","Check the plugin name spelling matches the server/plugin directory.","Verify autoCode.root/server config resolves to the real server tree.","Follow the documented plugin v2 structure (initialize/router.go, enter.go aggregation) before generating code into it."],"exampleFix":"// before\nserver/plugin/mytool/  // no plugin.go\n// after\n// server/plugin/mytool/plugin.go\ntype Mytool struct{}\nvar Plugin = new(Mytool)\nfunc (p *Mytool) Register(group *gin.RouterGroup) {}","handlingStrategy":"validation","validationCode":"pluginEnter := filepath.Join(cfg.AutoCode.Root, cfg.AutoCode.Server, \"plugin\", pkg, \"plugin.go\")\nif _, err := os.Stat(pluginEnter); err != nil {\n    return fmt.Errorf(\"initialize server/plugin/%s (plugin.go) before generating\", pkg)\n}","typeGuard":null,"tryCatchPattern":"if err := s.Create(info); err != nil {\n    if strings.Contains(err.Error(), \"缺少plugin\") {\n        // initialize the plugin skeleton then retry\n    }\n    return err\n}","preventionTips":["Initialize the backend plugin skeleton before generating code into it","Use the plugin generator tooling so plugin.go is created automatically","Verify the plugin name matches the server/plugin directory exactly"],"tags":["autocode","plugin","validation"],"backgroundTag":"missing-plugin-entry-file","analyzedSha":"3136500ef380842b0eb6c4daa87c3f8a47fcf9e0","analyzedAt":"2026-08-31T13:50:02.721Z","schemaVersion":2},"datasetVersion":"2026-08-31T19:17:28.585Z"}