glob/match/contains.go

28 lines
420 B
Go
Raw Normal View History

2016-01-08 20:14:31 +03:00
package match
import (
"fmt"
"strings"
)
type Contains struct {
Needle string
Not bool
}
func (self Contains) Match(s string) bool {
return strings.Contains(s, self.Needle) != self.Not
}
2016-01-09 02:34:41 +03:00
func (self Contains) Len() int {
return -1
}
2016-01-08 20:14:31 +03:00
func (self Contains) Kind() Kind {
return KindContains
}
func (self Contains) String() string {
return fmt.Sprintf("[contains:needle=%s not=%t]", self.Needle, self.Not)
}