...

Source file src/github.com/gobwas/glob/match/suffix.go

Documentation: github.com/gobwas/glob/match

     1  package match
     2  
     3  import (
     4  	"fmt"
     5  	"strings"
     6  )
     7  
     8  type Suffix struct {
     9  	Suffix string
    10  }
    11  
    12  func NewSuffix(s string) Suffix {
    13  	return Suffix{s}
    14  }
    15  
    16  func (self Suffix) Len() int {
    17  	return lenNo
    18  }
    19  
    20  func (self Suffix) Match(s string) bool {
    21  	return strings.HasSuffix(s, self.Suffix)
    22  }
    23  
    24  func (self Suffix) Index(s string) (int, []int) {
    25  	idx := strings.Index(s, self.Suffix)
    26  	if idx == -1 {
    27  		return -1, nil
    28  	}
    29  
    30  	return 0, []int{idx + len(self.Suffix)}
    31  }
    32  
    33  func (self Suffix) String() string {
    34  	return fmt.Sprintf("<suffix:%s>", self.Suffix)
    35  }
    36  

View as plain text