{"record":{"id":"5f5c97a243c0b137","repo":"flipped-aurora/gin-vue-admin","slug":"s-5f5c97","errorCode":null,"errorMessage":"读取模版文件夹[%s]失败!","messagePattern":"读取模版文件夹\\[(.+?)\\]失败!","errorType":"error_code","errorClass":null,"httpStatus":null,"severity":"error","filePath":"server/service/system/auto_code_package.go","lineNumber":309,"sourceCode":"\tfor i := 0; i < len(entries); i++ {\n\t\tif entries[i].IsDir() {\n\t\t\tif ignoreDirs[entries[i].Name()] {\n\t\t\t\tcontinue\n\t\t\t}\n\t\t\ttemplates = append(templates, entries[i].Name())\n\t\t}\n\t}\n\treturn templates, nil\n}\n\nfunc (s *autoCodePackage) templates(ctx context.Context, entity model.SysAutoCodePackage, info request.AutoCode, isPackage bool) (code map[string]string, asts map[string]ast.Ast, creates map[string]string, err error) {\n\tcode = make(map[string]string)\n\tasts = make(map[string]ast.Ast)\n\tcreates = make(map[string]string)\n\ttemplateDir := filepath.Join(global.GVA_CONFIG.AutoCode.Root, global.GVA_CONFIG.AutoCode.Server, \"resource\", entity.Template)\n\ttemplateDirs, err := os.ReadDir(templateDir)\n\tif err != nil {\n\t\treturn nil, nil, nil, errors.Wrapf(err, \"读取模版文件夹[%s]失败!\", templateDir)\n\t}\n\tfor i := 0; i < len(templateDirs); i++ {\n\t\tsecond := filepath.Join(templateDir, templateDirs[i].Name())\n\t\tswitch templateDirs[i].Name() {\n\t\tcase \"server\":\n\t\t\tif !info.GenerateServer && !isPackage {\n\t\t\t\tbreak\n\t\t\t}\n\t\t\tvar secondDirs []os.DirEntry\n\t\t\tsecondDirs, err = os.ReadDir(second)\n\t\t\tif err != nil {\n\t\t\t\treturn nil, nil, nil, errors.Wrapf(err, \"读取模版文件夹[%s]失败!\", second)\n\t\t\t}\n\t\t\tfor j := 0; j < len(secondDirs); j++ {\n\t\t\t\tif secondDirs[j].Name() == \".DS_Store\" {\n\t\t\t\t\tcontinue\n\t\t\t\t}\n\t\t\t\tthree := filepath.Join(second, secondDirs[j].Name())","sourceCodeStart":291,"sourceCodeEnd":327,"githubUrl":"https://github.com/flipped-aurora/gin-vue-admin/blob/3136500ef380842b0eb6c4daa87c3f8a47fcf9e0/server/service/system/auto_code_package.go#L291-L327","documentation":"The internal autoCodePackage.templates helper reads the top-level template directory <AutoCode.Root>/<AutoCode.Server>/resource/<entity.Template> via os.ReadDir and wraps any failure with \"读取模版文件夹[%s]失败!\". It means the configured template root for the selected package template does not exist or cannot be read.","triggerScenarios":"Invoking the package code-generation (CreateTemp / package create flow) where the entity.Template name (e.g. \"package\" or \"plugin\") has no matching folder under <Root>/<Server>/resource/, or the AutoCode Root/Server config values point at a wrong base path.","commonSituations":"Config auto-code.root / auto-code.server left at defaults after moving the project; selecting a custom template whose folder was never created; typo in the package's Template field in the DB record; resource folder not copied into a custom root layout.","solutions":["Check server config.yaml: auto-code.root and auto-code.server must resolve to the directory that actually contains resource/<template>.","Verify the template folder exists at the joined path printed in the error message and create/restore it if missing.","Fix the entity.Template value stored in the sys_auto_code_packages record (or re-create the package) so it matches an existing folder.","Ensure the process user has read access to the path."],"exampleFix":"// before: config.yaml\nauto-code:\n  root: /home/me/old-project\n// after\nauto-code:\n  root: .\n  server: .  # so ./resource/<template> resolves","handlingStrategy":"validation","validationCode":"dir := filepath.Join(cfg.AutoCode.Root, cfg.AutoCode.Server, \"resource\", entity.Template)\nif info, err := os.Stat(dir); err != nil || !info.IsDir() {\n    return fmt.Errorf(\"模板目录 %s 不存在，请检查 auto-code.root/server 配置\", dir)\n}","typeGuard":null,"tryCatchPattern":"code, asts, creates, err := pkgSvc.CreateTemp(ctx, entity, info)\nif err != nil && strings.Contains(err.Error(), \"读取模版文件夹\") {\n    log.Printf(\"模板目录缺失: %v\", err)\n    return fmt.Errorf(\"请确认 auto-code 配置与 resource/%s 模板目录\", entity.Template)\n}","preventionTips":["Keep auto-code.root and auto-code.server aligned with the actual project layout","Before creating a package, verify its Template value corresponds to an existing folder","Ship the whole resource/ tree in deployments","Stat the template dir in a pre-flight check before starting generation"],"tags":["filesystem","go","codegen","config"],"backgroundTag":"directory-not-found","analyzedSha":"3136500ef380842b0eb6c4daa87c3f8a47fcf9e0","analyzedAt":"2026-08-31T13:50:02.721Z","schemaVersion":2},"datasetVersion":"2026-08-31T19:17:28.585Z"}