all: Run gofumpt -l -w .

This commit is contained in:
Bjørn Erik Pedersen
2024-01-28 22:34:10 +01:00
parent 982d9513e7
commit a795acbcd8
77 changed files with 102 additions and 203 deletions

View File

@@ -26,8 +26,7 @@ func New() *Namespace {
}
// Namespace provides template functions for the "cast" namespace.
type Namespace struct {
}
type Namespace struct{}
// ToInt converts v to an int.
func (ns *Namespace) ToInt(v any) (int, error) {

View File

@@ -14,14 +14,13 @@
package collections
import (
"errors"
"fmt"
"reflect"
"strings"
"github.com/gohugoio/hugo/common/hreflect"
"github.com/gohugoio/hugo/common/maps"
"errors"
)
// Merge creates a copy of the final parameter in params and merges the preceding

View File

@@ -14,11 +14,10 @@
package collections
import (
"errors"
"fmt"
"reflect"
"errors"
"github.com/mitchellh/hashstructure"
)

View File

@@ -876,7 +876,7 @@ func BenchmarkWhereOps(b *testing.B) {
j := rand.Intn(i + 1)
seq[i], seq[j] = seq[j], seq[i]
}
//results, err = ns.Where(context.Background(), test.seq, test.key, test.op, test.match)
// results, err = ns.Where(context.Background(), test.seq, test.key, test.op, test.match)
runOps := func(b *testing.B, op, match string) {
_, err := ns.Where(ctx, seq, "foo", op, match)
if err != nil {
@@ -901,5 +901,4 @@ func BenchmarkWhereOps(b *testing.B) {
runOps(b, "like", "^bar")
}
})
}

View File

@@ -118,7 +118,7 @@ func (ns *Namespace) HMAC(h any, k any, m any, e ...any) (string, error) {
return "", err
}
var encoding = "hex"
encoding := "hex"
if len(e) > 0 && e[0] != nil {
encoding, err = cast.ToStringE(e[0])
if err != nil {
@@ -134,5 +134,4 @@ func (ns *Namespace) HMAC(h any, k any, m any, e ...any) (string, error) {
default:
return "", fmt.Errorf("%q is not a supported encoding method", encoding)
}
}

View File

@@ -12,8 +12,7 @@ import (
const name = "css"
// Namespace provides template functions for the "css" namespace.
type Namespace struct {
}
type Namespace struct{}
// Quoted returns a string that needs to be quoted in CSS.
func (ns *Namespace) Quoted(v any) css.QuotedString {

View File

@@ -72,7 +72,6 @@ func TestGetCSV(t *testing.T) {
false,
},
} {
c.Run(test.url, func(c *qt.C) {
msg := qt.Commentf("Test %d", i)
@@ -119,7 +118,6 @@ func TestGetCSV(t *testing.T) {
c.Assert(got, qt.Not(qt.IsNil), msg)
c.Assert(got, qt.DeepEquals, test.expect, msg)
})
}
}
@@ -164,9 +162,7 @@ func TestGetJSON(t *testing.T) {
map[string]any{"gomeetup": []any{"Sydney", "San Francisco", "Stockholm"}},
},
} {
c.Run(test.url, func(c *qt.C) {
msg := qt.Commentf("Test %d", i)
ns := newTestNs()
@@ -208,7 +204,6 @@ func TestGetJSON(t *testing.T) {
c.Assert(int(ns.deps.Log.LoggCount(logg.LevelError)), qt.Equals, 0, msg)
c.Assert(got, qt.Not(qt.IsNil), msg)
c.Assert(got, qt.DeepEquals, test.expect)
})
}
}
@@ -263,9 +258,7 @@ func TestHeaders(t *testing.T) {
},
},
} {
c.Run(test.name, func(c *qt.C) {
ns := newTestNs()
// Setup HTTP test server
@@ -275,7 +268,6 @@ func TestHeaders(t *testing.T) {
c.Assert(r.URL.String(), qt.Equals, "http://gohugo.io/api?foo")
w.Write([]byte("{}"))
r.Header.Write(&headers)
})
defer func() { srv.Close() }()
@@ -296,9 +288,7 @@ func TestHeaders(t *testing.T) {
_, err := ns.GetCSV(",", args...)
return err
})
})
}
}

View File

@@ -15,11 +15,10 @@
package images
import (
"errors"
"image"
"sync"
"errors"
"github.com/bep/overlayfs"
"github.com/gohugoio/hugo/resources/images"

View File

@@ -101,7 +101,7 @@ func TestNSConfig(t *testing.T) {
// cast path to string for afero.WriteFile
sp, err := cast.ToStringE(test.path)
c.Assert(err, qt.IsNil)
afero.WriteFile(ns.deps.Fs.Source, filepath.Join(bcfg.WorkingDir(), sp), test.input, 0755)
afero.WriteFile(ns.deps.Fs.Source, filepath.Join(bcfg.WorkingDir(), sp), test.input, 0o755)
result, err := ns.Config(test.path)

View File

@@ -20,8 +20,7 @@ import (
qt "github.com/frankban/quicktest"
)
type Test struct {
}
type Test struct{}
func (t *Test) MyTestMethod() string {
return "abcde"

View File

@@ -215,7 +215,6 @@ func (ns *Namespace) applyOpToScalarsOrSlices(opName string, op func(x, y float6
return
}
return
}
func (ns *Namespace) toFloatsE(v any) ([]float64, bool, error) {

View File

@@ -154,7 +154,6 @@ func (ns *Namespace) Join(elements ...any) (string, error) {
// extraneous slashes are removed.
func (ns *Namespace) Clean(path any) (string, error) {
spath, err := cast.ToStringE(path)
if err != nil {
return "", err
}

View File

@@ -70,7 +70,6 @@ func (ns *Namespace) FindRESubmatch(expr string, content any, limit ...any) ([][
}
return re.FindAllStringSubmatch(conv, n), nil
}
// ReplaceRE returns a copy of s, replacing all matches of the regular

View File

@@ -83,6 +83,7 @@ func TestFindRESubmatch(t *testing.T) {
c.Check(result, qt.DeepEquals, test.expect)
}
}
func TestReplaceRE(t *testing.T) {
t.Parallel()
c := qt.New(t)

View File

@@ -111,5 +111,4 @@ func BenchmarkTruncate(b *testing.B) {
ns.Truncate(10, "I have a <a href='/markdown'>Markdown link</a> inside")
}
})
}

View File

@@ -124,7 +124,7 @@ func TestFormat(t *testing.T) {
}
})
//Issue #9084
// Issue #9084
c.Run("TZ America/Los_Angeles", func(c *qt.C) {
c.Parallel()
@@ -136,9 +136,7 @@ func TestFormat(t *testing.T) {
c.Assert(err, qt.IsNil)
c.Assert(d, qt.Equals, "11:00:00 am Pacific Daylight Time")
})
}
func TestDuration(t *testing.T) {

View File

@@ -23,7 +23,6 @@ import (
const numTemplateVariants = 3
type shortcodeVariant struct {
// The possible variants: lang, outFormat, suffix
// gtag
// gtag.html

View File

@@ -2,9 +2,8 @@ package transform
import (
"bytes"
"strings"
"errors"
"strings"
"github.com/gohugoio/hugo/parser"
"github.com/gohugoio/hugo/parser/metadecoders"

View File

@@ -189,7 +189,6 @@ func (ns *Namespace) AbsLangURL(s any) (string, error) {
// of any ./ or ../ elements. If the argument list is empty, JoinPath returns
// an empty string.
func (ns *Namespace) JoinPath(elements ...any) (string, error) {
if len(elements) == 0 {
return "", nil
}