From d90e37e0c6e812f9913bf256c9c81aa05b7a08aa Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B8rn=20Erik=20Pedersen?= Date: Wed, 2 Dec 2020 13:23:25 +0100 Subject: all: Format code with gofumpt See https://github.com/mvdan/gofumpt --- common/collections/append.go | 1 - common/collections/append_test.go | 43 ++++++++++++++++++++++++++------------- common/collections/slice_test.go | 14 ++++++------- 3 files changed, 36 insertions(+), 22 deletions(-) (limited to 'common/collections') diff --git a/common/collections/append.go b/common/collections/append.go index b56455bc9..d6fb89241 100644 --- a/common/collections/append.go +++ b/common/collections/append.go @@ -51,7 +51,6 @@ func Append(to interface{}, from ...interface{}) (interface{}, error) { } else if !fromt.AssignableTo(tot) { // Fall back to a []interface{} slice. return appendToInterfaceSliceFromValues(tov, fromv) - } } } diff --git a/common/collections/append_test.go b/common/collections/append_test.go index 4086570b8..7d6117de8 100644 --- a/common/collections/append_test.go +++ b/common/collections/append_test.go @@ -36,28 +36,44 @@ func TestAppend(t *testing.T) { {nil, []interface{}{"a", "b"}, []string{"a", "b"}}, {nil, []interface{}{nil}, []interface{}{nil}}, {[]interface{}{}, []interface{}{[]string{"c", "d", "e"}}, []string{"c", "d", "e"}}, - {tstSlicers{&tstSlicer{"a"}, &tstSlicer{"b"}}, + { + tstSlicers{&tstSlicer{"a"}, &tstSlicer{"b"}}, []interface{}{&tstSlicer{"c"}}, - tstSlicers{&tstSlicer{"a"}, &tstSlicer{"b"}, &tstSlicer{"c"}}}, - {&tstSlicers{&tstSlicer{"a"}, &tstSlicer{"b"}}, + tstSlicers{&tstSlicer{"a"}, &tstSlicer{"b"}, &tstSlicer{"c"}}, + }, + { + &tstSlicers{&tstSlicer{"a"}, &tstSlicer{"b"}}, []interface{}{&tstSlicer{"c"}}, - tstSlicers{&tstSlicer{"a"}, + tstSlicers{ + &tstSlicer{"a"}, &tstSlicer{"b"}, - &tstSlicer{"c"}}}, - {testSlicerInterfaces{&tstSlicerIn1{"a"}, &tstSlicerIn1{"b"}}, + &tstSlicer{"c"}, + }, + }, + { + testSlicerInterfaces{&tstSlicerIn1{"a"}, &tstSlicerIn1{"b"}}, []interface{}{&tstSlicerIn1{"c"}}, - testSlicerInterfaces{&tstSlicerIn1{"a"}, &tstSlicerIn1{"b"}, &tstSlicerIn1{"c"}}}, + testSlicerInterfaces{&tstSlicerIn1{"a"}, &tstSlicerIn1{"b"}, &tstSlicerIn1{"c"}}, + }, //https://github.com/gohugoio/hugo/issues/5361 - {[]string{"a", "b"}, []interface{}{tstSlicers{&tstSlicer{"a"}, &tstSlicer{"b"}}}, - []interface{}{"a", "b", &tstSlicer{"a"}, &tstSlicer{"b"}}}, - {[]string{"a", "b"}, []interface{}{&tstSlicer{"a"}}, - []interface{}{"a", "b", &tstSlicer{"a"}}}, + { + []string{"a", "b"}, + []interface{}{tstSlicers{&tstSlicer{"a"}, &tstSlicer{"b"}}}, + []interface{}{"a", "b", &tstSlicer{"a"}, &tstSlicer{"b"}}, + }, + { + []string{"a", "b"}, + []interface{}{&tstSlicer{"a"}}, + []interface{}{"a", "b", &tstSlicer{"a"}}, + }, // Errors {"", []interface{}{[]string{"a", "b"}}, false}, // No string concatenation. - {"ab", + { + "ab", []interface{}{"c"}, - false}, + false, + }, } { result, err := Append(test.start, test.addend...) @@ -71,5 +87,4 @@ func TestAppend(t *testing.T) { c.Assert(err, qt.IsNil) c.Assert(result, qt.DeepEquals, test.expected) } - } diff --git a/common/collections/slice_test.go b/common/collections/slice_test.go index 3ebfe6d11..93bad84da 100644 --- a/common/collections/slice_test.go +++ b/common/collections/slice_test.go @@ -20,11 +20,13 @@ import ( qt "github.com/frankban/quicktest" ) -var _ Slicer = (*tstSlicer)(nil) -var _ Slicer = (*tstSlicerIn1)(nil) -var _ Slicer = (*tstSlicerIn2)(nil) -var _ testSlicerInterface = (*tstSlicerIn1)(nil) -var _ testSlicerInterface = (*tstSlicerIn1)(nil) +var ( + _ Slicer = (*tstSlicer)(nil) + _ Slicer = (*tstSlicerIn1)(nil) + _ Slicer = (*tstSlicerIn2)(nil) + _ testSlicerInterface = (*tstSlicerIn1)(nil) + _ testSlicerInterface = (*tstSlicerIn1)(nil) +) type testSlicerInterface interface { Name() string @@ -54,7 +56,6 @@ func (p *tstSlicerIn1) Slice(in interface{}) (interface{}, error) { default: return nil, errors.New("invalid type") } - } return result, nil } @@ -120,5 +121,4 @@ func TestSlice(t *testing.T) { c.Assert(test.expected, qt.DeepEquals, result, errMsg) } - } -- cgit v1.2.3