summaryrefslogtreecommitdiffstats
path: root/src/tokenizer.go
diff options
context:
space:
mode:
authorRyan Boehning <ryanboehning@gmail.com>2018-02-17 14:01:06 -0800
committerJunegunn Choi <junegunn.c@gmail.com>2018-03-13 14:56:55 +0900
commit21b94d2de5bdf2d8c4e8107e4c197a2abc1e7275 (patch)
treed7255fcd66e512a40016ac220d84574f22c0d551 /src/tokenizer.go
parent24236860c89242ac0a341ff911c93f25032dc051 (diff)
Make fzf pass go vet
Add String() methods to types, so they can be printed with %s. Change some %s format specifiers to %v, when the default string representation is good enough. In Go 1.10, `go test` triggers a parallel `go vet`. So this also makes fzf pass `go test`. Close #1236 Close #1219
Diffstat (limited to 'src/tokenizer.go')
-rw-r--r--src/tokenizer.go11
1 files changed, 11 insertions, 0 deletions
diff --git a/src/tokenizer.go b/src/tokenizer.go
index 6c1d8cab..208d79e9 100644
--- a/src/tokenizer.go
+++ b/src/tokenizer.go
@@ -2,6 +2,7 @@ package fzf
import (
"bytes"
+ "fmt"
"regexp"
"strconv"
"strings"
@@ -23,12 +24,22 @@ type Token struct {
prefixLength int32
}
+// String returns the string representation of a Token.
+func (t Token) String() string {
+ return fmt.Sprintf("Token{text: %s, prefixLength: %d}", t.text, t.prefixLength)
+}
+
// Delimiter for tokenizing the input
type Delimiter struct {
regex *regexp.Regexp
str *string
}
+// String returns the string representation of a Delimeter.
+func (d Delimiter) String() string {
+ return fmt.Sprintf("Delimiter{regex: %v, str: &%q}", d.regex, *d.str)
+}
+
func newRange(begin int, end int) Range {
if begin == 1 {
begin = rangeEllipsis