summaryrefslogtreecommitdiff
path: root/match/prefix.go
diff options
context:
space:
mode:
authorEyal Posener <[email protected]>2017-05-08 06:33:45 +0300
committerGitHub <[email protected]>2017-05-08 06:33:45 +0300
commit6dd6a04d241b1c267d686d5b4b112f8e8d3f7338 (patch)
tree28d9df10ae15cb7736f6a57f904eaf95083097ee /match/prefix.go
parente8f6dfad584cb1e3082bc7ea82f8c0551dd944b3 (diff)
parent328144c31b5abd57be42f18ffb8a442c78619097 (diff)
Merge pull request #8 from posener/move-match
Move match
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)
+}