mirror of
https://github.com/projectdiscovery/nuclei
synced 2026-06-08 16:50:47 +00:00
29 lines
833 B
Smarty
29 lines
833 B
Smarty
// Warning - This is generated code
|
|
package {{.SourcePackage}}
|
|
|
|
import (
|
|
"github.com/projectdiscovery/utils/memoize"
|
|
|
|
{{range .Imports}}
|
|
{{.Name}} {{.Path}}
|
|
{{end}}
|
|
)
|
|
|
|
{{range .Functions}}
|
|
{{ .SignatureWithPrefix "memoized" }} {
|
|
hash := "{{ .Name }}" {{range .Params}}{{if ne .Type "context.Context"}} + ":" + fmt.Sprint({{.Name}}){{end}}{{end}}
|
|
|
|
v, err, _ := protocolstate.Memoizer.Do(hash, func() (interface{}, error) {
|
|
return {{.Name}}({{.ParamsNames}})
|
|
})
|
|
if err != nil {
|
|
return {{.ResultFirstFieldDefaultValue}}, err
|
|
}
|
|
if value, ok := v.({{.ResultFirstFieldType}}); ok {
|
|
return value, nil
|
|
}
|
|
|
|
return {{.ResultFirstFieldDefaultValue}}, errors.New("could not convert cached result")
|
|
}
|
|
{{end}}
|