mirror of
https://github.com/gohugoio/hugo.git
synced 2025-09-01 22:42:45 +02:00
all: Run gofumpt -l -w .
This commit is contained in:
@@ -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) {
|
||||
|
@@ -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
|
||||
|
@@ -14,11 +14,10 @@
|
||||
package collections
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"fmt"
|
||||
"reflect"
|
||||
|
||||
"errors"
|
||||
|
||||
"github.com/mitchellh/hashstructure"
|
||||
)
|
||||
|
||||
|
@@ -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")
|
||||
}
|
||||
})
|
||||
|
||||
}
|
||||
|
@@ -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)
|
||||
}
|
||||
|
||||
}
|
||||
|
@@ -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 {
|
||||
|
@@ -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
|
||||
})
|
||||
|
||||
})
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -15,11 +15,10 @@
|
||||
package images
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"image"
|
||||
"sync"
|
||||
|
||||
"errors"
|
||||
|
||||
"github.com/bep/overlayfs"
|
||||
"github.com/gohugoio/hugo/resources/images"
|
||||
|
||||
|
@@ -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)
|
||||
|
||||
|
@@ -20,8 +20,7 @@ import (
|
||||
qt "github.com/frankban/quicktest"
|
||||
)
|
||||
|
||||
type Test struct {
|
||||
}
|
||||
type Test struct{}
|
||||
|
||||
func (t *Test) MyTestMethod() string {
|
||||
return "abcde"
|
||||
|
@@ -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) {
|
||||
|
@@ -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
|
||||
}
|
||||
|
@@ -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
|
||||
|
@@ -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)
|
||||
|
@@ -111,5 +111,4 @@ func BenchmarkTruncate(b *testing.B) {
|
||||
ns.Truncate(10, "I have a <a href='/markdown'>Markdown link</a> inside")
|
||||
}
|
||||
})
|
||||
|
||||
}
|
||||
|
@@ -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) {
|
||||
|
@@ -23,7 +23,6 @@ import (
|
||||
const numTemplateVariants = 3
|
||||
|
||||
type shortcodeVariant struct {
|
||||
|
||||
// The possible variants: lang, outFormat, suffix
|
||||
// gtag
|
||||
// gtag.html
|
||||
|
@@ -2,9 +2,8 @@ package transform
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"strings"
|
||||
|
||||
"errors"
|
||||
"strings"
|
||||
|
||||
"github.com/gohugoio/hugo/parser"
|
||||
"github.com/gohugoio/hugo/parser/metadecoders"
|
||||
|
@@ -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
|
||||
}
|
||||
|
Reference in New Issue
Block a user