{"record":{"id":"4fe1dd5d5cf1a27a","repo":"projectdiscovery/nuclei","slug":"could-not-write-go-template-v","errorCode":null,"errorMessage":"could not write go template: %v","messagePattern":"could not write go template: (.+?)","errorType":"console","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkg/js/devtools/bindgen/cmd/bindgen/main.go","lineNumber":63,"sourceCode":"\t}\n\tfor _, module := range modules {\n\t\tlog.Printf(\"[module] Generating %s\", module)\n\n\t\tdata, err := generator.CreateTemplateData(filepath.Join(dir, module), \"github.com/projectdiscovery/nuclei/v3/pkg/js/libs/\")\n\t\tif err != nil {\n\t\t\treturn fmt.Errorf(\"could not create template data: %v\", err)\n\t\t}\n\n\t\tprefixed := \"lib\" + module\n\t\t// if !goOnly {\n\t\t// \terr = data.WriteJSTemplate(filepath.Join(generatedDir, \"js/\"+prefixed), module)\n\t\t// \tif err != nil {\n\t\t// \t\treturn fmt.Errorf(\"could not write js template: %v\", err)\n\t\t// \t}\n\t\t// }\n\t\terr = data.WriteGoTemplate(path.Join(generatedDir, \"go/\"+prefixed), module)\n\t\tif err != nil {\n\t\t\treturn fmt.Errorf(\"could not write go template: %v\", err)\n\t\t}\n\t\t// disabled for now since we have static website for docs\n\t\t// err = data.WriteMarkdownLibraryDocumentation(path.Join(generatedDir, \"markdown/\"), module)\n\t\t// if err != nil {\n\t\t// \treturn fmt.Errorf(\"could not write markdown template: %v\", err)\n\t\t// }\n\n\t\t// err = data.WriteMarkdownIndexTemplate(path.Join(generatedDir, \"markdown/\"))\n\t\t// if err != nil {\n\t\t// \treturn fmt.Errorf(\"could not write markdown index template: %v\", err)\n\t\t// }\n\t\tdata.InitNativeScripts()\n\t}\n\treturn nil\n}\n","sourceCodeStart":45,"sourceCodeEnd":79,"githubUrl":"https://github.com/projectdiscovery/nuclei/blob/265b3a3dec374741614e342f813c10f8b38d2bb7/pkg/js/devtools/bindgen/cmd/bindgen/main.go#L45-L79","documentation":"TemplateData.WriteGoTemplate failed while writing generated bindings into generatedDir/go/lib<module>. Causes: cannot create the output directory (permissions, read-only checkout), file write errors, or template execution hitting an AST/type shape the generator does not handle.","triggerScenarios":"bindgen successfully parsed the module but failed emitting pkg/js/generated/go/lib<module>/*.go — unwritable path, disk full, or a generator bug on exotic type declarations.","commonSituations":"Running codegen in a read-only clone or as a user without write access; a stale generated dir with root-owned files from an earlier sudo run; newly added struct shapes (generics, embedded aliases) the emitter chokes on.","solutions":["Check write permission on pkg/js/generated and fix ownership of stale files (sudo chown -R $USER pkg/js/generated)","Clean the target dir (git clean -xfd pkg/js/generated) and regenerate via make devtools-all","If it persists on a specific module's types, minimize the offending declaration and report it against the devtool"],"exampleFix":"# before\n./bindgen ./pkg/js/libs/smb   # fails writing generated output\n\n# after\ngit clean -xfd pkg/js/generated && make devtools-all","handlingStrategy":"try-catch","validationCode":"if err := os.MkdirAll(filepath.Join(generatedDir, \"go\"), 0o755); err != nil {\n    log.Fatalf(\"output dir not writable: %v\", err)\n}","typeGuard":null,"tryCatchPattern":"On WriteGoTemplate failure, surface the wrapped error, fix permissions/staleness of pkg/js/generated, clean it (git clean -xfd pkg/js/generated), and re-run the make target once.","preventionTips":["Never run codegen with sudo (leaves root-owned generated files)","Keep the checkout writable and the generated dir clean before regenerating","Commit regenerated output promptly so failures are diffable"],"tags":["devtools","bindgen","code-generation","filesystem"],"backgroundTag":null,"analyzedSha":"265b3a3dec374741614e342f813c10f8b38d2bb7","analyzedAt":"2026-08-15T20:05:51.855Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}