Skip to content

Commit a795acb

Browse files
committed
all: Run gofumpt -l -w .
1 parent 982d951 commit a795acb

File tree

77 files changed

+109
-210
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

77 files changed

+109
-210
lines changed

cache/filecache/filecache_config.go

+1-3
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
package filecache
1616

1717
import (
18+
"errors"
1819
"fmt"
1920
"path"
2021
"path/filepath"
@@ -24,8 +25,6 @@ import (
2425
"github.com/gohugoio/hugo/common/maps"
2526
"github.com/gohugoio/hugo/config"
2627

27-
"errors"
28-
2928
"github.com/mitchellh/mapstructure"
3029
"github.com/spf13/afero"
3130
)
@@ -225,7 +224,6 @@ func DecodeConfig(fs afero.Fs, bcfg config.BaseConfig, m map[string]any) (Config
225224

226225
// Resolves :resourceDir => /myproject/resources etc., :cacheDir => ...
227226
func resolveDirPlaceholder(fs afero.Fs, bcfg config.BaseConfig, placeholder string) (cacheDir string, isResource bool, err error) {
228-
229227
switch strings.ToLower(placeholder) {
230228
case ":resourcedir":
231229
return "", true, nil

cache/filecache/filecache_pruner.go

-2
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,6 @@ func (c *Cache) Prune(force bool) (int, error) {
6060
counter := 0
6161

6262
err := afero.Walk(c.Fs, "", func(name string, info os.FileInfo, err error) error {
63-
6463
if info == nil {
6564
return nil
6665
}
@@ -69,7 +68,6 @@ func (c *Cache) Prune(force bool) (int, error) {
6968

7069
if info.IsDir() {
7170
f, err := c.Fs.Open(name)
72-
7371
if err != nil {
7472
// This cache dir may not exist.
7573
return nil

codegen/methods.go

-1
Original file line numberDiff line numberDiff line change
@@ -461,7 +461,6 @@ func collectMethodsRecursive(pkg string, f []*ast.Field) []string {
461461
pkg,
462462
tt.Methods.List)...)
463463
}
464-
465464
} else {
466465
// Embedded, but in a different file/package. Return the
467466
// package.Name and deal with that later.

common/collections/append_test.go

+7-5
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ func TestAppend(t *testing.T) {
5555
[]any{&tstSlicerIn1{"c"}},
5656
testSlicerInterfaces{&tstSlicerIn1{"a"}, &tstSlicerIn1{"b"}, &tstSlicerIn1{"c"}},
5757
},
58-
//https://github.com/gohugoio/hugo/issues/5361
58+
// https://github.com/gohugoio/hugo/issues/5361
5959
{
6060
[]string{"a", "b"},
6161
[]any{tstSlicers{&tstSlicer{"a"}, &tstSlicer{"b"}}},
@@ -102,22 +102,25 @@ func TestAppendToMultiDimensionalSlice(t *testing.T) {
102102
from []any
103103
expected any
104104
}{
105-
{[][]string{{"a", "b"}},
105+
{
106+
[][]string{{"a", "b"}},
106107
[]any{[]string{"c", "d"}},
107108
[][]string{
108109
{"a", "b"},
109110
{"c", "d"},
110111
},
111112
},
112-
{[][]string{{"a", "b"}},
113+
{
114+
[][]string{{"a", "b"}},
113115
[]any{[]string{"c", "d"}, []string{"e", "f"}},
114116
[][]string{
115117
{"a", "b"},
116118
{"c", "d"},
117119
{"e", "f"},
118120
},
119121
},
120-
{[][]string{{"a", "b"}},
122+
{
123+
[][]string{{"a", "b"}},
121124
[]any{[]int{1, 2}},
122125
false,
123126
},
@@ -130,7 +133,6 @@ func TestAppendToMultiDimensionalSlice(t *testing.T) {
130133
c.Assert(result, qt.DeepEquals, test.expected)
131134
}
132135
}
133-
134136
}
135137

136138
func TestAppendShouldMakeACopyOfTheInputSlice(t *testing.T) {

common/collections/slice.go

-1
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,6 @@ func StringSliceToInterfaceSlice(ss []string) []any {
7373
result[i] = s
7474
}
7575
return result
76-
7776
}
7877

7978
type SortedStringSlice []string

common/collections/slice_test.go

-1
Original file line numberDiff line numberDiff line change
@@ -135,5 +135,4 @@ func TestSortedStringSlice(t *testing.T) {
135135
c.Assert(s.Count("b"), qt.Equals, 3)
136136
c.Assert(s.Count("z"), qt.Equals, 0)
137137
c.Assert(s.Count("a"), qt.Equals, 1)
138-
139138
}

common/hexec/exec.go

+2-4
Original file line numberDiff line numberDiff line change
@@ -19,11 +19,10 @@ import (
1919
"errors"
2020
"fmt"
2121
"io"
22-
"regexp"
23-
"strings"
24-
2522
"os"
2623
"os/exec"
24+
"regexp"
25+
"strings"
2726

2827
"github.com/cli/safeexec"
2928
"github.com/gohugoio/hugo/config"
@@ -142,7 +141,6 @@ func (e *Exec) New(name string, arg ...any) (Runner, error) {
142141
}
143142

144143
return cm.command(arg...)
145-
146144
}
147145

148146
// Npx is a convenience method to create a Runner running npx --no-install <name> <args.

common/htime/time_test.go

-4
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,6 @@ func TestTimeFormatter(t *testing.T) {
5353
c.Assert(f.Format(june06, ":time_long"), qt.Equals, "02:09:37 UTC")
5454
c.Assert(f.Format(june06, ":time_medium"), qt.Equals, "02:09:37")
5555
c.Assert(f.Format(june06, ":time_short"), qt.Equals, "02:09")
56-
5756
})
5857

5958
c.Run("Custom layouts English", func(c *qt.C) {
@@ -68,7 +67,6 @@ func TestTimeFormatter(t *testing.T) {
6867
c.Assert(f.Format(june06, ":time_long"), qt.Equals, "2:09:37 am UTC")
6968
c.Assert(f.Format(june06, ":time_medium"), qt.Equals, "2:09:37 am")
7069
c.Assert(f.Format(june06, ":time_short"), qt.Equals, "2:09 am")
71-
7270
})
7371

7472
c.Run("English", func(c *qt.C) {
@@ -107,9 +105,7 @@ func TestTimeFormatter(t *testing.T) {
107105
c.Assert(tr.MonthWide(date.Month()), qt.Equals, monthWideNorway)
108106
c.Assert(f.Format(date, "January"), qt.Equals, monthWideNorway)
109107
}
110-
111108
})
112-
113109
}
114110

115111
func BenchmarkTimeFormatter(b *testing.B) {

common/maps/maps_test.go

-1
Original file line numberDiff line numberDiff line change
@@ -192,5 +192,4 @@ func TestLookupEqualFold(t *testing.T) {
192192
v, found = LookupEqualFold(m2, "b")
193193
c.Assert(found, qt.IsTrue)
194194
c.Assert(v, qt.Equals, "bv")
195-
196195
}

common/maps/params_test.go

-1
Original file line numberDiff line numberDiff line change
@@ -154,7 +154,6 @@ func TestParamsSetAndMerge(t *testing.T) {
154154
"a": "av",
155155
"c": "cv",
156156
})
157-
158157
}
159158

160159
func TestParamsIsZero(t *testing.T) {

common/paths/url.go

-1
Original file line numberDiff line numberDiff line change
@@ -163,7 +163,6 @@ func Uglify(in string) string {
163163
// If ParseRequestURI fails, the input is just converted to OS specific slashes and returned.
164164
func UrlToFilename(s string) (string, bool) {
165165
u, err := url.ParseRequestURI(s)
166-
167166
if err != nil {
168167
return filepath.FromSlash(s), false
169168
}

common/text/transform_test.go

-4
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,6 @@ line 3`
5757
c := qt.New(t)
5858

5959
c.Assert(collected, qt.DeepEquals, []string{"line 1\n", "line 2\n", "\n", "line 3"})
60-
6160
}
6261

6362
func BenchmarkVisitLinesAfter(b *testing.B) {
@@ -68,9 +67,6 @@ func BenchmarkVisitLinesAfter(b *testing.B) {
6867

6968
for i := 0; i < b.N; i++ {
7069
VisitLinesAfter(lines, func(s string) {
71-
7270
})
73-
7471
}
75-
7672
}

common/types/convert.go

-1
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,6 @@ func ToStringSlicePreserveStringE(v any) ([]string, error) {
8080
default:
8181
return nil, fmt.Errorf("failed to convert %T to a string slice", v)
8282
}
83-
8483
}
8584

8685
// TypeToString converts v to a string if it's a valid string type.

common/types/convert_test.go

-1
Original file line numberDiff line numberDiff line change
@@ -45,5 +45,4 @@ func TestToDuration(t *testing.T) {
4545
c.Assert(ToDuration("200"), qt.Equals, 200*time.Millisecond)
4646
c.Assert(ToDuration("4m"), qt.Equals, 4*time.Minute)
4747
c.Assert(ToDuration("asdfadf"), qt.Equals, time.Duration(0))
48-
4948
}

compare/compare_strings_test.go

-1
Original file line numberDiff line numberDiff line change
@@ -79,5 +79,4 @@ func BenchmarkStringSort(b *testing.B) {
7979
})
8080
}
8181
})
82-
8382
}

config/allconfig/load_test.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ weight = 3
5050
title = "Svenska"
5151
weight = 4
5252
`
53-
if err := os.WriteFile(configFilename, []byte(config), 0666); err != nil {
53+
if err := os.WriteFile(configFilename, []byte(config), 0o666); err != nil {
5454
b.Fatal(err)
5555
}
5656
d := ConfigSourceDescriptor{

config/configLoader.go

-1
Original file line numberDiff line numberDiff line change
@@ -208,7 +208,6 @@ func LoadConfigFromDir(sourceFs afero.Fs, configDir, environment string) (Provid
208208
}
209209

210210
return cfg, dirnames, nil
211-
212211
}
213212

214213
var keyAliases maps.KeyRenamer

config/defaultConfigProvider.go

-1
Original file line numberDiff line numberDiff line change
@@ -370,7 +370,6 @@ func (c *defaultConfigProvider) SetDefaultMergeStrategy() {
370370
}
371371
return false
372372
})
373-
374373
}
375374

376375
func (c *defaultConfigProvider) getNestedKeyAndMap(key string, create bool) (string, maps.Params) {

config/env.go

-1
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,6 @@ func GetMemoryLimit() uint64 {
4949
if v := stringToGibabyte(mem); v > 0 {
5050
return v
5151
}
52-
5352
}
5453

5554
// There is a FreeMemory function, but as the kernel in most situations

config/security/whitelist_test.go

-1
Original file line numberDiff line numberDiff line change
@@ -43,5 +43,4 @@ func TestWhitelist(t *testing.T) {
4343
c.Assert(w.Accept("bar"), qt.IsTrue)
4444
c.Assert(w.Accept("mbar"), qt.IsFalse)
4545
})
46-
4746
}

deploy/deployConfig.go

+1-3
Original file line numberDiff line numberDiff line change
@@ -14,11 +14,10 @@
1414
package deploy
1515

1616
import (
17+
"errors"
1718
"fmt"
1819
"regexp"
1920

20-
"errors"
21-
2221
"github.com/gobwas/glob"
2322
"github.com/gohugoio/hugo/config"
2423
hglob "github.com/gohugoio/hugo/hugofs/glob"
@@ -132,7 +131,6 @@ var DefaultConfig = DeployConfig{
132131

133132
// DecodeConfig creates a config from a given Hugo configuration.
134133
func DecodeConfig(cfg config.Provider) (DeployConfig, error) {
135-
136134
dcfg := DefaultConfig
137135

138136
if !cfg.IsSet(deploymentConfigKey) {

htesting/test_helpers_test.go

-2
Original file line numberDiff line numberDiff line change
@@ -20,12 +20,10 @@ import (
2020
)
2121

2222
func TestExtractMinorVersionFromGoTag(t *testing.T) {
23-
2423
c := qt.New(t)
2524

2625
c.Assert(extractMinorVersionFromGoTag("go1.17"), qt.Equals, 17)
2726
c.Assert(extractMinorVersionFromGoTag("go1.16.7"), qt.Equals, 16)
2827
c.Assert(extractMinorVersionFromGoTag("go1.17beta1"), qt.Equals, 17)
2928
c.Assert(extractMinorVersionFromGoTag("asdfadf"), qt.Equals, -1)
30-
3129
}

hugofs/createcounting_fs.go

+1-3
Original file line numberDiff line numberDiff line change
@@ -33,9 +33,7 @@ type DuplicatesReporter interface {
3333
ReportDuplicates() string
3434
}
3535

36-
var (
37-
_ FilesystemUnwrapper = (*createCountingFs)(nil)
38-
)
36+
var _ FilesystemUnwrapper = (*createCountingFs)(nil)
3937

4038
func NewCreateCountingFs(fs afero.Fs) afero.Fs {
4139
return &createCountingFs{Fs: fs, fileCount: make(map[string]int)}

hugofs/glob/glob_test.go

-1
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,6 @@ func TestGetGlob(t *testing.T) {
7575
}
7676

7777
func BenchmarkGetGlob(b *testing.B) {
78-
7978
runBench := func(name string, cache *globCache, search string) {
8079
b.Run(name, func(b *testing.B) {
8180
g, err := GetGlob("**/foo")

hugolib/404_test.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -41,8 +41,8 @@ Data: {{ len .Data }}|
4141
IntegrationTestConfig{
4242
T: t,
4343
TxtarString: files,
44-
//LogLevel: logg.LevelTrace,
45-
//Verbose: true,
44+
// LogLevel: logg.LevelTrace,
45+
// Verbose: true,
4646
},
4747
).Build()
4848

hugolib/config.go

+3-4
Original file line numberDiff line numberDiff line change
@@ -157,7 +157,7 @@ module github.com/bep/mymod
157157

158158
tempDir := os.TempDir()
159159
cacheDir := filepath.Join(tempDir, "hugocache")
160-
if err := os.MkdirAll(cacheDir, 0777); err != nil {
160+
if err := os.MkdirAll(cacheDir, 0o777); err != nil {
161161
return nil, err
162162
}
163163
cfg.Set("cacheDir", cacheDir)
@@ -168,11 +168,11 @@ module github.com/bep/mymod
168168

169169
fs := afero.NewOsFs()
170170

171-
if err := afero.WriteFile(fs, filepath.Join(tempDir, "hugo.toml"), []byte(configToml), 0644); err != nil {
171+
if err := afero.WriteFile(fs, filepath.Join(tempDir, "hugo.toml"), []byte(configToml), 0o644); err != nil {
172172
return nil, err
173173
}
174174

175-
if err := afero.WriteFile(fs, filepath.Join(tempDir, "go.mod"), []byte(goMod), 0644); err != nil {
175+
if err := afero.WriteFile(fs, filepath.Join(tempDir, "go.mod"), []byte(goMod), 0o644); err != nil {
176176
return nil, err
177177
}
178178

@@ -181,5 +181,4 @@ module github.com/bep/mymod
181181
return nil, err
182182
}
183183
return conf.Base, err
184-
185184
}

hugolib/language_test.go

+1-3
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ import (
2626
func TestI18n(t *testing.T) {
2727
c := qt.New(t)
2828

29-
//https://github.com/gohugoio/hugo/issues/7804
29+
// https://github.com/gohugoio/hugo/issues/7804
3030
c.Run("pt-br should be case insensitive", func(c *qt.C) {
3131
b := newTestSitesBuilder(c)
3232
langCode := func() string {
@@ -76,12 +76,10 @@ name = "foo-a"
7676

7777
menus := b.H.Sites[0].Menus()
7878
c.Assert(menus, qt.HasLen, 1)
79-
8079
})
8180
}
8281

8382
func TestLanguageNumberFormatting(t *testing.T) {
84-
8583
b := newTestSitesBuilder(t)
8684
b.WithConfigFile("toml", `
8785
baseURL = "https://example.org"

langs/language_test.go

-3
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@ import (
2323
)
2424

2525
func TestCollator(t *testing.T) {
26-
2726
c := qt.New(t)
2827

2928
var wg sync.WaitGroup
@@ -43,7 +42,6 @@ func TestCollator(t *testing.T) {
4342
}()
4443
}
4544
wg.Wait()
46-
4745
}
4846

4947
func BenchmarkCollator(b *testing.B) {
@@ -75,5 +73,4 @@ func BenchmarkCollator(b *testing.B) {
7573
}
7674
})
7775
})
78-
7976
}

lazy/init_test.go

-1
Original file line numberDiff line numberDiff line change
@@ -234,5 +234,4 @@ func TestResetError(t *testing.T) {
234234
r = true
235235
_, err = i.Do(context.Background())
236236
c.Assert(err, qt.IsNil)
237-
238237
}

0 commit comments

Comments
 (0)