{"record":{"id":"9dc877c5190330f1","repo":"flipped-aurora/gin-vue-admin","slug":"filpath-s","errorCode":null,"errorMessage":"[filpath:%s]非法模版后缀!","messagePattern":"\\[filpath:(.+?)\\]非法模版后缀!","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"server/service/system/auto_code_package.go","lineNumber":331,"sourceCode":"\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())\n\t\t\t\tif !secondDirs[j].IsDir() {\n\t\t\t\t\text := filepath.Ext(secondDirs[j].Name())\n\t\t\t\t\tif ext != \".tpl\" {\n\t\t\t\t\t\treturn nil, nil, nil, errors.Errorf(\"[filpath:%s]非法模版后缀!\", three)\n\t\t\t\t\t}\n\t\t\t\t\tname := strings.TrimSuffix(secondDirs[j].Name(), ext)\n\t\t\t\t\tif name == \"main.go\" || name == \"plugin.go\" {\n\t\t\t\t\t\tpluginInitialize := &ast.PluginInitializeV2{\n\t\t\t\t\t\t\tType:        ast.TypePluginInitializeV2,\n\t\t\t\t\t\t\tPath:        filepath.Join(global.GVA_CONFIG.AutoCode.Root, global.GVA_CONFIG.AutoCode.Server, \"plugin\", entity.PackageName, name),\n\t\t\t\t\t\t\tPluginPath:  filepath.Join(global.GVA_CONFIG.AutoCode.Root, global.GVA_CONFIG.AutoCode.Server, \"plugin\", \"register.go\"),\n\t\t\t\t\t\t\tImportPath:  fmt.Sprintf(`\"%s/plugin/%s\"`, global.GVA_CONFIG.AutoCode.Module, entity.PackageName),\n\t\t\t\t\t\t\tPackageName: entity.PackageName,\n\t\t\t\t\t\t}\n\t\t\t\t\t\tasts[pluginInitialize.PluginPath+\"=>\"+pluginInitialize.Type.String()] = pluginInitialize\n\t\t\t\t\t\tcreates[three] = pluginInitialize.Path\n\t\t\t\t\t\tcontinue\n\t\t\t\t\t}\n\t\t\t\t\treturn nil, nil, nil, errors.Errorf(\"[filpath:%s]非法模版文件!\", three)\n\t\t\t\t}\n\t\t\t\tswitch secondDirs[j].Name() {\n\t\t\t\tcase \"api\", \"router\", \"service\":","sourceCodeStart":313,"sourceCodeEnd":349,"githubUrl":"https://github.com/flipped-aurora/gin-vue-admin/blob/3136500ef380842b0eb6c4daa87c3f8a47fcf9e0/server/service/system/auto_code_package.go#L313-L349","documentation":"Inside <templateDir>/server, any non-directory entry must end with .tpl. If a file has another extension, templates() aborts with errors.Errorf(\"[filpath:%s]非法模版后缀!\"). The generator treats resource templates as strict .tpl assets, so stray files break the whole generation run.","triggerScenarios":"A file that is not a .tpl (e.g. README.md, .DS_Store is skipped, main.go backup, editor temp file like foo.tpl~ or foo.go) sits directly under <templateDir>/server; also .tpl.bak or any renamed file in the \"server\" level.","commonSituations":"Developers adding notes or compiled artifacts into the template folder; OS/editor leaving backup/temp files; copying real Go source instead of .tpl templates into server/.","solutions":["Open the path shown in the error and either delete the offending file or rename it to <name>.tpl.","Move non-template documentation out of the server template folder.","Delete editor/OS temp files (foo~, *.swp, .bak) before generating.","Keep custom template files always with the .tpl extension so the walker accepts them."],"exampleFix":"// before\nresource/package/server/notes.md\n// after\nmv resource/package/server/notes.md docs/  # or rename to notes.md.tpl if it is a template","handlingStrategy":"validation","validationCode":"entries, _ := os.ReadDir(filepath.Join(templateDir, \"server\"))\nfor _, e := range entries {\n    if e.IsDir() || e.Name() == \".DS_Store\" {\n        continue\n    }\n    if filepath.Ext(e.Name()) != \".tpl\" {\n        return fmt.Errorf(\"server 层存在非 .tpl 文件: %s\", e.Name())\n    }\n}","typeGuard":"func isTpl(name string) bool { return filepath.Ext(name) == \".tpl\" }","tryCatchPattern":"if err := runGeneration(); err != nil {\n    var pathErr interface{ Error() string }\n    if strings.Contains(err.Error(), \"非法模版后缀\") {\n        return fmt.Errorf(\"模板目录混入非 .tpl 文件，按报错路径清理后重试: %w\", err)\n    }\n    _ = pathErr\n    return err\n}","preventionTips":["Treat resource/<template>/server as a generator-only directory; keep docs elsewhere","Clean editor temp/backup files (*.bak, *~, *.swp) before generating","Always name new templates with the .tpl extension","Add .gitignore rules for OS junk files in resource/"],"tags":["codegen","go","validation","templates"],"backgroundTag":"invalid-template-file","analyzedSha":"3136500ef380842b0eb6c4daa87c3f8a47fcf9e0","analyzedAt":"2026-08-31T13:50:02.721Z","schemaVersion":2},"datasetVersion":"2026-08-31T19:17:28.585Z"}