mirror of https://github.com/gobwas/glob.git
37 lines
441 B
Go
37 lines
441 B
Go
|
package match
|
||
|
|
||
|
import (
|
||
|
"strings"
|
||
|
"fmt"
|
||
|
)
|
||
|
|
||
|
|
||
|
|
||
|
|
||
|
|
||
|
type Suffix struct {
|
||
|
Suffix string
|
||
|
}
|
||
|
|
||
|
func (self Suffix) Kind() Kind {
|
||
|
return KindSuffix
|
||
|
}
|
||
|
|
||
|
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)
|
||
|
}
|
||
|
|
||
|
|