glob/match/raw.go

36 lines
474 B
Go
Raw Normal View History

2015-12-24 17:54:54 +03:00
package match
import (
"fmt"
2016-01-08 20:14:31 +03:00
"strings"
2015-12-24 17:54:54 +03:00
)
// raw represents raw string to match
type Raw struct {
Str string
}
func (self Raw) Match(s string) bool {
return self.Str == s
}
func (self Raw) Kind() Kind {
return KindRaw
}
2016-01-08 20:14:31 +03:00
func (self Raw) Index(s string) (index, min, max int) {
index = strings.Index(s, self.Str)
2015-12-24 17:54:54 +03:00
if index == -1 {
return
}
2016-01-08 20:14:31 +03:00
min = len(self.Str)
max = min
2015-12-24 17:54:54 +03:00
return
}
func (self Raw) String() string {
return fmt.Sprintf("[raw:%s]", self.Str)
}