glob/match/suffix.go

35 lines
480 B
Go
Raw Normal View History

2015-12-24 17:54:54 +03:00
package match
import (
"fmt"
2016-01-09 02:34:41 +03:00
"strings"
2015-12-24 17:54:54 +03:00
)
type Suffix struct {
Suffix string
}
func (self Suffix) Kind() Kind {
return KindSuffix
}
2016-01-09 02:34:41 +03:00
func (self Suffix) Len() int {
return -1
}
2015-12-24 17:54:54 +03:00
func (self Suffix) Search(s string) (i int, l int, ok bool) {
if self.Match(s) {
return 0, len(s), true
}
return
}
func (self Suffix) Match(s string) bool {
return strings.HasSuffix(s, self.Suffix)
}
func (self Suffix) String() string {
return fmt.Sprintf("[suffix:%s]", self.Suffix)
}