nuclei/pkg/js/libs/smb/memo.smbghost.go
Mzack9999 4c7a0f424e
Transparent Memoization via func Annotation (#4742)
* initial implementation with manual code generation

* testing generation

* refactor to package methods + auto memoize

* more memos

* fixing signatures

* refactor

* adding gen util

* adding util

* regenerate memoized files

---------

Co-authored-by: Tarun Koyalwar <tarun@projectdiscovery.io>
2024-03-01 18:40:18 +05:30

26 lines
574 B
Go
Executable File

// Warning - This is generated code
package smb
import (
"errors"
"fmt"
"github.com/projectdiscovery/nuclei/v3/pkg/protocols/common/protocolstate"
)
func memoizeddetectSMBGhost(host string, port int) (bool, error) {
hash := "detectSMBGhost" + ":" + fmt.Sprint(host) + ":" + fmt.Sprint(port)
v, err, _ := protocolstate.Memoizer.Do(hash, func() (interface{}, error) {
return detectSMBGhost(host, port)
})
if err != nil {
return false, err
}
if value, ok := v.(bool); ok {
return value, nil
}
return false, errors.New("could not convert cached result")
}