summaryrefslogtreecommitdiff
path: root/match/prefix.go
diff options
context:
space:
mode:
authorEyal Posener <[email protected]>2017-05-07 19:53:55 +0300
committerEyal Posener <[email protected]>2017-05-07 19:57:41 +0300
commit6fb4875efa1f536813da29972a0c3250bde8b5eb (patch)
treec7ee97d75ed8d1d6c734256e3ff789402571bcca /match/prefix.go
parente8f6dfad584cb1e3082bc7ea82f8c0551dd944b3 (diff)
Move match to a separate package
Diffstat (limited to 'match/prefix.go')
-rw-r--r--match/prefix.go15
1 files changed, 15 insertions, 0 deletions
diff --git a/match/prefix.go b/match/prefix.go
new file mode 100644
index 0000000..d54902d
--- /dev/null
+++ b/match/prefix.go
@@ -0,0 +1,15 @@
+package match
+
+import "strings"
+
+// Prefix is a simple Matcher, if the word is it's prefix, there is a match
+type Prefix string
+
+func (a Prefix) String() string {
+ return string(a)
+}
+
+// Match returns true if a has the prefix as prefix
+func (a Prefix) Match(prefix string) bool {
+ return strings.HasPrefix(string(a), prefix)
+}