matcher.go
func (m *SuffixMatcher) Match(str string) (offset int, matchStr string) {
	offset = -1

	// at least 1 character is required to match suffix and matcher
	d := len(str) - len(m.suffix)
	if d < 1 {
		return
	}

	for i, r := range str {
		if i > d {
			return
		}

		// peek string to match to suffix pattern
		if i != 0 && m.suffix == str[i:i+len(m.suffix)] {
			offset = i + len(m.suffix)
			matchStr = str[:i]
			return
		}

		if !m.matcher.MatchRune(r) {
			return
		}
	}
	return
}
func (m *SuffixMatcher) Match(str string) (offset int, matchStr string) {
	offset = -1

	// at least 1 character is required to match suffix and matcher
	d := len(str) - len(m.suffix)
	if d < 1 {
		return
	}

	for i, r := range str {
		if i > d {
			return
		}

		// peek string to match to suffix pattern
		if i != 0 && m.suffix == str[i:i+len(m.suffix)] {
			offset = i + len(m.suffix)
			matchStr = str[:i]
			return
		}

		if !m.matcher.MatchRune(r) {
			return
		}
	}
	return
}
func ( m * SuffixMatcher ) Match ( str string ) ( offset int , matchStr string ) { offset = - 1 // at least 1 character is required to match suffix and matcher d := len ( str ) - len ( m . suffix ) if d < 1 { return } for i , r := range str { if i > d { return } // peek string to match to suffix pattern if i != 0 && m . suffix == str [ i : i + len ( m . suffix ) ] { offset = i + len ( m . suffix ) matchStr = str [ : i ] return } if ! m . matcher . MatchRune ( r ) { return } } return }
// Match processes the given string until it has its suffix in the next or
// encounters a rune that doesn't match.
Match processes the given string until it has its suffix in the next or encounters a rune that doesn t match .