diff options
author | Bjørn Erik Pedersen <bjorn.erik.pedersen@gmail.com> | 2020-12-02 13:23:25 +0100 |
---|---|---|
committer | Bjørn Erik Pedersen <bjorn.erik.pedersen@gmail.com> | 2020-12-03 13:12:58 +0100 |
commit | d90e37e0c6e812f9913bf256c9c81aa05b7a08aa (patch) | |
tree | 7b1b14464eefec1188ca2eed53c64e4823453cc9 /tpl | |
parent | 32471b57bde51c55a15dbf1db75d6e5f7232c347 (diff) |
all: Format code with gofumpt
See https://github.com/mvdan/gofumpt
Diffstat (limited to 'tpl')
92 files changed, 393 insertions, 347 deletions
diff --git a/tpl/cast/cast_test.go b/tpl/cast/cast_test.go index d3f8d9733..c6219728b 100644 --- a/tpl/cast/cast_test.go +++ b/tpl/cast/cast_test.go @@ -15,7 +15,6 @@ package cast import ( "html/template" - "testing" qt "github.com/frankban/quicktest" diff --git a/tpl/cast/docshelper.go b/tpl/cast/docshelper.go index a497f6e8a..035db1740 100644 --- a/tpl/cast/docshelper.go +++ b/tpl/cast/docshelper.go @@ -41,7 +41,6 @@ func init() { } return docshelper.DocProvider{"tpl": map[string]interface{}{"funcs": namespaces}} - } docshelper.AddDocProviderFunc(docsProvider) diff --git a/tpl/cast/init.go b/tpl/cast/init.go index 3aee6f036..3f1f3f253 100644 --- a/tpl/cast/init.go +++ b/tpl/cast/init.go @@ -51,7 +51,6 @@ func init() { ) return ns - } internal.AddTemplateFuncsNamespace(f) diff --git a/tpl/cast/init_test.go b/tpl/cast/init_test.go index 73d9d5adc..dd024b775 100644 --- a/tpl/cast/init_test.go +++ b/tpl/cast/init_test.go @@ -38,5 +38,4 @@ func TestInit(t *testing.T) { c.Assert(found, qt.Equals, true) c.Assert(ns.Context(), hqt.IsSameType, &Namespace{}) - } 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"}}, + { |