36 lines
604 B
Go
36 lines
604 B
Go
package pprof
|
|
|
|
import (
|
|
"regexp"
|
|
|
|
gomock "github.com/golang/mock/gomock"
|
|
)
|
|
|
|
func boolPtr(b bool) *bool { return &b }
|
|
|
|
func intPtr(n int) *int { return &n }
|
|
|
|
var _ gomock.Matcher = (*regexMatcher)(nil)
|
|
|
|
type regexMatcher struct {
|
|
regexp *regexp.Regexp
|
|
}
|
|
|
|
func (r *regexMatcher) Matches(x interface{}) bool {
|
|
s, ok := x.(string)
|
|
if !ok {
|
|
return false
|
|
}
|
|
return r.regexp.MatchString(s)
|
|
}
|
|
|
|
func (r *regexMatcher) String() string {
|
|
return "regular expression " + r.regexp.String()
|
|
}
|
|
|
|
func newRegexMatcher(regex string) *regexMatcher {
|
|
return ®exMatcher{
|
|
regexp: regexp.MustCompile(regex),
|
|
}
|
|
}
|