/* package gcustom provides a simple mechanism for creating custom Gomega matchers */ package gcustom import ( "fmt" "reflect" "strings" "text/template" "github.com/onsi/gomega/format" ) var interfaceType = reflect.TypeOf((*interface{})(nil)).Elem() var errInterface = reflect.TypeOf((*error)(nil)).Elem() var defaultTemplate = template.Must(ParseTemplate("{{if .Failure}}Custom matcher failed for:{{else}}Custom matcher succeeded (but was expected to fail) for:{{end}}\n{{.FormattedActual}}")) func formatObject(object any, indent ...uint) string { indentation := uint(0) if len(indent) > 0 { indentation = indent[0] } return format.Object(object, indentation) } /* ParseTemplate allows you to precompile templates for MakeMatcher's custom matchers. Use ParseTemplate if you are concerned about performance and would like to avoid repeatedly parsing failure message templates. The data made available to the template is documented in the WithTemplate() method of CustomGomegaMatcher. Once parsed you can pass the template in either as an argument to MakeMatcher(matchFunc,