all: Format code with gofumpt

See https://github.com/mvdan/gofumpt
This commit is contained in:
Bjørn Erik Pedersen
2020-12-02 13:23:25 +01:00
parent 32471b57bd
commit d90e37e0c6
442 changed files with 1426 additions and 2254 deletions

View File

@@ -34,5 +34,4 @@ func (ns *Namespace) Append(args ...interface{}) (interface{}, error) {
from := args[:len(args)-1]
return collections.Append(to, from...)
}

View File

@@ -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)
}
}
}

View File

@@ -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
}

View File

@@ -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")
}
}

View File

@@ -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.

View File

@@ -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 {

View File

@@ -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))
}

View File

@@ -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)

View File

@@ -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.

View File

@@ -165,7 +165,6 @@ func convertNumber(v reflect.Value, to reflect.Kind) (reflect.Value, error) {
}
return n, nil
}
func newSliceElement(items interface{}) interface{} {

View File

@@ -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) {
}
}
})
}
}

View File

@@ -65,5 +65,4 @@ func (ns *Namespace) SymDiff(s2, s1 interface{}) (interface{}, error) {
}
return slice.Interface(), nil
}

View File

@@ -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))
}

View File

@@ -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",
},