summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorJunegunn Choi <junegunn.c@gmail.com>2021-02-28 18:28:21 +0900
committerJunegunn Choi <junegunn.c@gmail.com>2021-02-28 18:28:21 +0900
commitbb0502ff4429580e363be708ff301c35479144e3 (patch)
treed2ec8db2becfdfa09d8d622786ddcfed0e0b2d2a /src
parentc256442245836d959f329c10c4b2476a7f438ced (diff)
Check gofmt in `make test`
Diffstat (limited to 'src')
-rw-r--r--src/cache_test.go4
-rw-r--r--src/options_test.go2
-rw-r--r--src/pattern.go4
-rw-r--r--src/pattern_test.go2
-rw-r--r--src/result_test.go12
5 files changed, 12 insertions, 12 deletions
diff --git a/src/cache_test.go b/src/cache_test.go
index 5d9c5cc5..02425345 100644
--- a/src/cache_test.go
+++ b/src/cache_test.go
@@ -6,8 +6,8 @@ func TestChunkCache(t *testing.T) {
cache := NewChunkCache()
chunk1p := &Chunk{}
chunk2p := &Chunk{count: chunkSize}
- items1 := []Result{Result{}}
- items2 := []Result{Result{}, Result{}}
+ items1 := []Result{{}}
+ items2 := []Result{{}, {}}
cache.Add(chunk1p, "foo", items1)
cache.Add(chunk2p, "foo", items1)
cache.Add(chunk2p, "bar", items2)
diff --git a/src/options_test.go b/src/options_test.go
index b1068964..791b55d4 100644
--- a/src/options_test.go
+++ b/src/options_test.go
@@ -102,7 +102,7 @@ func TestIrrelevantNth(t *testing.T) {
t.Errorf("nth should be empty: %v", opts.Nth)
}
}
- for _, words := range [][]string{[]string{"--nth", "..,3", "+x"}, []string{"--nth", "3,1..", "+x"}, []string{"--nth", "..-1,1", "+x"}} {
+ for _, words := range [][]string{{"--nth", "..,3", "+x"}, {"--nth", "3,1..", "+x"}, {"--nth", "..-1,1", "+x"}} {
{
opts := defaultOptions()
parseOptions(opts, words)
diff --git a/src/pattern.go b/src/pattern.go
index 56dc830f..4a7a87a6 100644
--- a/src/pattern.go
+++ b/src/pattern.go
@@ -337,7 +337,7 @@ func (p *Pattern) MatchItem(item *Item, withPos bool, slab *util.Slab) (*Result,
func (p *Pattern) basicMatch(item *Item, withPos bool, slab *util.Slab) (Offset, int, *[]int) {
var input []Token
if len(p.nth) == 0 {
- input = []Token{Token{text: &item.text, prefixLength: 0}}
+ input = []Token{{text: &item.text, prefixLength: 0}}
} else {
input = p.transformInput(item)
}
@@ -350,7 +350,7 @@ func (p *Pattern) basicMatch(item *Item, withPos bool, slab *util.Slab) (Offset,
func (p *Pattern) extendedMatch(item *Item, withPos bool, slab *util.Slab) ([]Offset, int, *[]int) {
var input []Token
if len(p.nth) == 0 {
- input = []Token{Token{text: &item.text, prefixLength: 0}}
+ input = []Token{{text: &item.text, prefixLength: 0}}
} else {
input = p.transformInput(item)
}
diff --git a/src/pattern_test.go b/src/pattern_test.go
index 5a622952..b95d1513 100644
--- a/src/pattern_test.go
+++ b/src/pattern_test.go
@@ -131,7 +131,7 @@ func TestCaseSensitivity(t *testing.T) {
func TestOrigTextAndTransformed(t *testing.T) {
pattern := BuildPattern(true, algo.FuzzyMatchV2, true, CaseSmart, false, true, true, []Range{}, Delimiter{}, []rune("jg"))
tokens := Tokenize("junegunn", Delimiter{})
- trans := Transform(tokens, []Range{Range{1, 1}})
+ trans := Transform(tokens, []Range{{1, 1}})
origBytes := []byte("junegunn.choi")
for _, extended := range []bool{false, true} {
diff --git a/src/result_test.go b/src/result_test.go
index 1f3d338c..4084fdb7 100644
--- a/src/result_test.go
+++ b/src/result_test.go
@@ -18,8 +18,8 @@ func withIndex(i *Item, index int) *Item {
func TestOffsetSort(t *testing.T) {
offsets := []Offset{
- Offset{3, 5}, Offset{2, 7},
- Offset{1, 3}, Offset{2, 9}}
+ {3, 5}, {2, 7},
+ {1, 3}, {2, 9}}
sort.Sort(ByOrder(offsets))
if offsets[0][0] != 1 || offsets[0][1] != 3 ||
@@ -84,13 +84,13 @@ func TestResultRank(t *testing.T) {
// Sort by relevance
item3 := buildResult(
- withIndex(&Item{}, 2), []Offset{Offset{1, 3}, Offset{5, 7}}, 3)
+ withIndex(&Item{}, 2), []Offset{{1, 3}, {5, 7}}, 3)
item4 := buildResult(
- withIndex(&Item{}, 2), []Offset{Offset{1, 2}, Offset{6, 7}}, 4)
+ withIndex(&Item{}, 2), []Offset{{1, 2}, {6, 7}}, 4)
item5 := buildResult(
- withIndex(&Item{}, 2), []Offset{Offset{1, 3}, Offset{5, 7}}, 5)
+ withIndex(&Item{}, 2), []Offset{{1, 3}, {5, 7}}, 5)
item6 := buildResult(
- withIndex(&Item{}, 2), []Offset{Offset{1, 2}, Offset{6, 7}}, 6)
+ withIndex(&Item{}, 2), []Offset{{1, 2}, {6, 7}}, 6)
items = []Result{item1, item2, item3, item4, item5, item6}
sort.Sort(ByRelevance(items))
if !(items[0] == item6 && items[1] == item5 &&