Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/gohugoio/hugo.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBjørn Erik Pedersen <bjorn.erik.pedersen@gmail.com>2020-12-02 15:23:25 +0300
committerBjørn Erik Pedersen <bjorn.erik.pedersen@gmail.com>2020-12-03 15:12:58 +0300
commitd90e37e0c6e812f9913bf256c9c81aa05b7a08aa (patch)
tree7b1b14464eefec1188ca2eed53c64e4823453cc9 /tpl/collections
parent32471b57bde51c55a15dbf1db75d6e5f7232c347 (diff)
all: Format code with gofumpt
See https://github.com/mvdan/gofumpt
Diffstat (limited to 'tpl/collections')
-rw-r--r--tpl/collections/append.go1
-rw-r--r--tpl/collections/append_test.go7
-rw-r--r--tpl/collections/apply.go1
-rw-r--r--tpl/collections/apply_test.go5
-rw-r--r--tpl/collections/collections.go7
-rw-r--r--tpl/collections/collections_test.go16
-rw-r--r--tpl/collections/complement_test.go4
-rw-r--r--tpl/collections/index_test.go1
-rw-r--r--tpl/collections/merge_test.go30
-rw-r--r--tpl/collections/reflect_helpers.go1
-rw-r--r--tpl/collections/sort_test.go2
-rw-r--r--tpl/collections/symdiff.go1
-rw-r--r--tpl/collections/symdiff_test.go1
-rw-r--r--tpl/collections/where_test.go9
14 files changed, 41 insertions, 45 deletions
diff --git a/tpl/collections/append.go b/tpl/collections/append.go
index 297328dc8..50fafe3d9 100644
--- a/tpl/collections/append.go
+++ b/tpl/collections/append.go
@@ -34,5 +34,4 @@ func (ns *Namespace) Append(args ...interface{}) (interface{}, error) {
from := args[:len(args)-1]
return collections.Append(to, from...)
-
}
diff --git a/tpl/collections/append_test.go b/tpl/collections/append_test.go
index a254601b4..9dcc7d2b9 100644
--- a/tpl/collections/append_test.go
+++ b/tpl/collections/append_test.go
@@ -40,9 +40,11 @@ func TestAppend(t *testing.T) {
{"", []interface{}{[]string{"a", "b"}}, false},
{[]string{"a", "b"}, []interface{}{}, false},
// No string concatenation.
- {"ab",
+ {
+ "ab",
[]interface{}{"c"},
- false},
+ false,
+ },
} {
errMsg := qt.Commentf("[%d]", i)
@@ -62,5 +64,4 @@ func TestAppend(t *testing.T) {
t.Fatalf("%s got\n%T: %v\nexpected\n%T: %v", errMsg, result, result, test.expected, test.expected)
}
}
-
}
diff --git a/tpl/collections/apply.go b/tpl/collections/apply.go
index 55d29d3a9..86554def1 100644
--- a/tpl/collections/apply.go
+++ b/tpl/collections/apply.go
@@ -52,7 +52,6 @@ func (ns *Namespace) Apply(seq interface{}, fname string, args ...interface{}) (
vv := seqv.Index(i)
vvv, err := applyFnToThis(fnv, vv, args...)
-
if err != nil {
return nil, err
}
diff --git a/tpl/collections/apply_test.go b/tpl/collections/apply_test.go
index f9199b6b6..98cb78b51 100644
--- a/tpl/collections/apply_test.go
+++ b/tpl/collections/apply_test.go
@@ -14,12 +14,11 @@
package collections
import (
+ "fmt"
"io"
"reflect"
"testing"
- "fmt"
-
qt "github.com/frankban/quicktest"
"github.com/gohugoio/hugo/deps"
"github.com/gohugoio/hugo/output"
@@ -58,7 +57,6 @@ func (templateFinder) GetFunc(name string) (reflect.Value, bool) {
}
return reflect.ValueOf(fmt.Sprint), true
-
}
func TestApply(t *testing.T) {
@@ -88,5 +86,4 @@ func TestApply(t *testing.T) {
if err == nil {
t.Errorf("apply with unknown func should fail")
}
-
}
diff --git a/tpl/collections/collections.go b/tpl/collections/collections.go
index d90467022..3521f9cd5 100644
--- a/tpl/collections/collections.go
+++ b/tpl/collections/collections.go
@@ -18,7 +18,6 @@ package collections
import (
"fmt"
"html/template"
-
"math/rand"
"net/url"
"reflect"
@@ -478,9 +477,9 @@ func (ns *Namespace) Seq(args ...interface{}) ([]int, error) {
return nil, errors.New("invalid arguments to Seq")
}
- var inc = 1
+ inc := 1
var last int
- var first = intArgs[0]
+ first := intArgs[0]
if len(intArgs) == 1 {
last = first
@@ -580,7 +579,6 @@ type intersector struct {
}
func (i *intersector) appendIfNotSeen(v reflect.Value) {
-
vi := v.Interface()
if !i.seen[vi] {
i.r = reflect.Append(i.r, v)
@@ -729,7 +727,6 @@ func (ns *Namespace) Uniq(seq interface{}) (interface{}, error) {
}
return slice.Interface(), nil
-
}
// KeyVals creates a key and values wrapper.
diff --git a/tpl/collections/collections_test.go b/tpl/collections/collections_test.go
index 21c8bfb56..a75ec9d16 100644
--- a/tpl/collections/collections_test.go
+++ b/tpl/collections/collections_test.go
@@ -17,7 +17,6 @@ import (
"errors"
"fmt"
"html/template"
-
"math/rand"
"reflect"
"testing"
@@ -195,8 +194,10 @@ func TestDictionary(t *testing.T) {
}{
{[]interface{}{"a", "b"}, map[string]interface{}{"a": "b"}},
{[]interface{}{[]string{"a", "b"}, "c"}, map[string]interface{}{"a": map[string]interface{}{"b": "c"}}},
- {[]interface{}{[]string{"a", "b"}, "c", []string{"a", "b2"}, "c2", "b", "c"},
- map[string]interface{}{"a": map[string]interface{}{"b": "c", "b2": "c2"}, "b": "c"}},
+ {
+ []interface{}{[]string{"a", "b"}, "c", []string{"a", "b2"}, "c2", "b", "c"},
+ map[string]interface{}{"a": map[string]interface{}{"b": "c", "b2": "c2"}, "b": "c"},
+ },
{[]interface{}{"a", 12, "b", []int{4}}, map[string]interface{}{"a": 12, "b": []int{4}}},
// errors
{[]interface{}{5, "b"}, false},
@@ -237,7 +238,6 @@ func TestReverse(t *testing.T) {
c.Assert(reversed, qt.IsNil)
_, err = ns.Reverse(43)
c.Assert(err, qt.Not(qt.IsNil))
-
}
func TestEchoParam(t *testing.T) {
@@ -369,8 +369,10 @@ func (p testPage) String() string {
return "p-" + p.Title
}
-type pagesPtr []*testPage
-type pagesVals []testPage
+type (
+ pagesPtr []*testPage
+ pagesVals []testPage
+)
var (
p1 = &testPage{"A"}
@@ -716,7 +718,6 @@ func TestSlice(t *testing.T) {
c.Assert(result, qt.DeepEquals, test.expected, errMsg)
}
-
}
func TestUnion(t *testing.T) {
@@ -907,7 +908,6 @@ type TstParams struct {
func (x TstParams) Params() maps.Params {
return x.params
-
}
type TstXIHolder struct {
diff --git a/tpl/collections/complement_test.go b/tpl/collections/complement_test.go
index d0e27353c..7e8d695b4 100644
--- a/tpl/collections/complement_test.go
+++ b/tpl/collections/complement_test.go
@@ -66,7 +66,8 @@ func TestComplement(t *testing.T) {
{"error", []interface{}{[]string{"c", "d"}, []string{"a", "b"}}, false},
{[]string{"a", "b", "c"}, []interface{}{[][]string{{"c", "d"}}}, false},
{
- []interface{}{[][]string{{"c", "d"}}}, []interface{}{[]string{"c", "d"}, []string{"a", "b"}},
+ []interface{}{[][]string{{"c", "d"}}},
+ []interface{}{[]string{"c", "d"}, []string{"a", "b"}},
[]interface{}{[][]string{{"c", "d"}}},
},
} {
@@ -93,5 +94,4 @@ func TestComplement(t *testing.T) {
c.Assert(err, qt.Not(qt.IsNil))
_, err = ns.Complement([]string{"a", "b"})
c.Assert(err, qt.Not(qt.IsNil))
-
}
diff --git a/tpl/collections/index_test.go b/tpl/collections/index_test.go
index 0c380d8d5..c690fe648 100644
--- a/tpl/collections/index_test.go
+++ b/tpl/collections/index_test.go
@@ -52,7 +52,6 @@ func TestIndex(t *testing.T) {
{[]int{0, 1}, []interface{}{nil}, nil, true},
{tstNoStringer{}, []interface{}{0}, nil, true},
} {
-
c.Run(fmt.Sprint(i), func(c *qt.C) {
errMsg := qt.Commentf("[%d] %v", i, test)
diff --git a/tpl/collections/merge_test.go b/tpl/collections/merge_test.go
index 92c973cd4..bde4d90b1 100644
--- a/tpl/collections/merge_test.go
+++ b/tpl/collections/merge_test.go
@@ -43,7 +43,8 @@ func TestMerge(t *testing.T) {
map[string]interface{}{"a": 42, "c": 3},
map[string]interface{}{"a": 1, "b": 2},
},
- map[string]interface{}{"a": 1, "b": 2, "c": 3}, false,
+ map[string]interface{}{"a": 1, "b": 2, "c": 3},
+ false,
},
{
"multi",
@@ -52,7 +53,8 @@ func TestMerge(t *testing.T) {
map[string]interface{}{"a": 1, "b": 2},
map[string]interface{}{"a": 9, "c": 4, "d": 7},
},
- map[string]interface{}{"a": 9, "b": 2, "c": 4, "d": 7, "e": 11}, false,
+ map[string]interface{}{"a": 9, "b": 2, "c": 4, "d": 7, "e": 11},
+ false,
},
{
"basic case insensitive",
@@ -60,7 +62,8 @@ func TestMerge(t *testing.T) {
map[string]interface{}{"A": 42, "c": 3},
map[string]interface{}{"a": 1, "b": 2},
},
- map[string]interface{}{"a": 1, "b": 2, "c": 3}, false,
+ map[string]interface{}{"a": 1, "b": 2, "c": 3},
+ false,
},
{
"nested",
@@ -68,7 +71,8 @@ func TestMerge(t *testing.T) {
map[string]interface{}{"a": 42, "c": 3, "b": map[string]interface{}{"d": 55, "e": 66, "f": 3}},
map[string]interface{}{"a": 1, "b": map[string]interface{}{"d": 1, "e": 2}},
},
- map[string]interface{}{"a": 1, "b": map[string]interface{}{"d": 1, "e": 2, "f": 3}, "c": 3}, false,
+ map[string]interface{}{"a": 1, "b": map[string]interface{}{"d": 1, "e": 2, "f": 3}, "c": 3},
+ false,
},
{
// https://github.com/gohugoio/hugo/issues/6633
@@ -77,7 +81,8 @@ func TestMerge(t *testing.T) {
map[string]interface{}{"a": 42, "c": 3},
maps.Params{"a": 1, "b": 2},
},
- maps.Params{"a": int(1), "b": int(2), "c": int(3)}, false,
+ maps.Params{"a": int(1), "b": int(2), "c": int(3)},
+ false,
},
{
"params dst, upper case src",
@@ -85,7 +90,8 @@ func TestMerge(t *testing.T) {
map[string]interface{}{"a": 42, "C": 3},
maps.Params{"a": 1, "b": 2},
},
- maps.Params{"a": int(1), "b": int(2), "c": int(3)}, false,
+ maps.Params{"a": int(1), "b": int(2), "c": int(3)},
+ false,
},
{
"params src",
@@ -93,7 +99,8 @@ func TestMerge(t *testing.T) {
maps.Params{"a": 42, "c": 3},
map[string]interface{}{"a": 1, "c": 2},
},
- map[string]interface{}{"a": int(1), "c": int(2)}, false,
+ map[string]interface{}{"a": int(1), "c": int(2)},
+ false,
},
{
"params src, upper case dst",
@@ -101,7 +108,8 @@ func TestMerge(t *testing.T) {
maps.Params{"a": 42, "c": 3},
map[string]interface{}{"a": 1, "C": 2},
},
- map[string]interface{}{"a": int(1), "C": int(2)}, false,
+ map[string]interface{}{"a": int(1), "C": int(2)},
+ false,
},
{
"nested, params dst",
@@ -109,7 +117,8 @@ func TestMerge(t *testing.T) {
map[string]interface{}{"a": 42, "c": 3, "b": map[string]interface{}{"d": 55, "e": 66, "f": 3}},
maps.Params{"a": 1, "b": maps.Params{"d": 1, "e": 2}},
},
- maps.Params{"a": 1, "b": maps.Params{"d": 1, "e": 2, "f": 3}, "c": 3}, false,
+ maps.Params{"a": 1, "b": maps.Params{"d": 1, "e": 2, "f": 3}, "c": 3},
+ false,
},
{
// https://github.com/gohugoio/hugo/issues/7899
@@ -118,7 +127,8 @@ func TestMerge(t *testing.T) {
map[string]interface{}{"k": "v"},
map[string]interface{}{"k": map[string]interface{}{"k2": "v2"}},
},
- map[string]interface{}{"k": map[string]interface{}{"k2": "v2"}}, false,
+ map[string]interface{}{"k": map[string]interface{}{"k2": "v2"}},
+ false,
},
{"src nil", []interface{}{nil, simpleMap}, simpleMap, false},
// Error cases.
diff --git a/tpl/collections/reflect_helpers.go b/tpl/collections/reflect_helpers.go
index 3d73b70e1..453d2f356 100644
--- a/tpl/collections/reflect_helpers.go
+++ b/tpl/collections/reflect_helpers.go
@@ -165,7 +165,6 @@ func convertNumber(v reflect.Value, to reflect.Kind) (reflect.Value, error) {
}
return n, nil
-
}
func newSliceElement(items interface{}) interface{} {
diff --git a/tpl/collections/sort_test.go b/tpl/collections/sort_test.go
index 75e23fc7b..4798b5090 100644
--- a/tpl/collections/sort_test.go
+++ b/tpl/collections/sort_test.go
@@ -238,7 +238,6 @@ func TestSort(t *testing.T) {
},
{nil, nil, "asc", false},
} {
-
t.Run(fmt.Sprintf("test%d", i), func(t *testing.T) {
var result interface{}
var err error
@@ -261,6 +260,5 @@ func TestSort(t *testing.T) {
}
}
})
-
}
}
diff --git a/tpl/collections/symdiff.go b/tpl/collections/symdiff.go
index 85a2076aa..e61814e26 100644
--- a/tpl/collections/symdiff.go
+++ b/tpl/collections/symdiff.go
@@ -65,5 +65,4 @@ func (ns *Namespace) SymDiff(s2, s1 interface{}) (interface{}, error) {
}
return slice.Interface(), nil
-
}
diff --git a/tpl/collections/symdiff_test.go b/tpl/collections/symdiff_test.go
index ac40fda55..120dfaac6 100644
--- a/tpl/collections/symdiff_test.go
+++ b/tpl/collections/symdiff_test.go
@@ -75,5 +75,4 @@ func TestSymDiff(t *testing.T) {
c.Assert(err, qt.Not(qt.IsNil))
_, err = ns.Complement([]string{"a", "b"})
c.Assert(err, qt.Not(qt.IsNil))
-
}
diff --git a/tpl/collections/where_test.go b/tpl/collections/where_test.go
index d6a1dd141..75ee109f9 100644
--- a/tpl/collections/where_test.go
+++ b/tpl/collections/where_test.go
@@ -62,7 +62,6 @@ func TestWhere(t *testing.T) {
}
return testVariants
-
}
for i, test := range []testt{
@@ -171,17 +170,17 @@ func TestWhere(t *testing.T) {
},
key: "B", match: "b2",
expect: []maps.Params{
- maps.Params{"a": "a2", "b": "b2"},
+ {"a": "a2", "b": "b2"},
},
},
{
seq: []maps.Params{
- maps.Params{
+ {
"a": map[string]interface{}{
"b": "b1",
},
},
- maps.Params{
+ {
"a": map[string]interface{}{
"b": "b2",
},
@@ -189,7 +188,7 @@ func TestWhere(t *testing.T) {
},
key: "A.B", match: "b2",
expect: []maps.Params{
- maps.Params{
+ {
"a": map[string]interface{}{
"b": "b2",
},