Skip to content

Commit

Permalink
all: Run gofumpt -l -w .
Browse files Browse the repository at this point in the history
  • Loading branch information
bep committed Jan 28, 2024
1 parent 982d951 commit a795acb
Show file tree
Hide file tree
Showing 77 changed files with 109 additions and 210 deletions.
4 changes: 1 addition & 3 deletions cache/filecache/filecache_config.go
Expand Up @@ -15,6 +15,7 @@
package filecache

import (
"errors"
"fmt"
"path"
"path/filepath"
Expand All @@ -24,8 +25,6 @@ import (
"github.com/gohugoio/hugo/common/maps"
"github.com/gohugoio/hugo/config"

"errors"

"github.com/mitchellh/mapstructure"
"github.com/spf13/afero"
)
Expand Down Expand Up @@ -225,7 +224,6 @@ func DecodeConfig(fs afero.Fs, bcfg config.BaseConfig, m map[string]any) (Config

// Resolves :resourceDir => /myproject/resources etc., :cacheDir => ...
func resolveDirPlaceholder(fs afero.Fs, bcfg config.BaseConfig, placeholder string) (cacheDir string, isResource bool, err error) {

switch strings.ToLower(placeholder) {
case ":resourcedir":
return "", true, nil
Expand Down
2 changes: 0 additions & 2 deletions cache/filecache/filecache_pruner.go
Expand Up @@ -60,7 +60,6 @@ func (c *Cache) Prune(force bool) (int, error) {
counter := 0

err := afero.Walk(c.Fs, "", func(name string, info os.FileInfo, err error) error {

if info == nil {
return nil
}
Expand All @@ -69,7 +68,6 @@ func (c *Cache) Prune(force bool) (int, error) {

if info.IsDir() {
f, err := c.Fs.Open(name)

if err != nil {
// This cache dir may not exist.
return nil
Expand Down
1 change: 0 additions & 1 deletion codegen/methods.go
Expand Up @@ -461,7 +461,6 @@ func collectMethodsRecursive(pkg string, f []*ast.Field) []string {
pkg,
tt.Methods.List)...)
}

} else {
// Embedded, but in a different file/package. Return the
// package.Name and deal with that later.
Expand Down
12 changes: 7 additions & 5 deletions common/collections/append_test.go
Expand Up @@ -55,7 +55,7 @@ func TestAppend(t *testing.T) {
[]any{&tstSlicerIn1{"c"}},
testSlicerInterfaces{&tstSlicerIn1{"a"}, &tstSlicerIn1{"b"}, &tstSlicerIn1{"c"}},
},
//https://github.com/gohugoio/hugo/issues/5361
// https://github.com/gohugoio/hugo/issues/5361
{
[]string{"a", "b"},
[]any{tstSlicers{&tstSlicer{"a"}, &tstSlicer{"b"}}},
Expand Down Expand Up @@ -102,22 +102,25 @@ func TestAppendToMultiDimensionalSlice(t *testing.T) {
from []any
expected any
}{
{[][]string{{"a", "b"}},
{
[][]string{{"a", "b"}},
[]any{[]string{"c", "d"}},
[][]string{
{"a", "b"},
{"c", "d"},
},
},
{[][]string{{"a", "b"}},
{
[][]string{{"a", "b"}},
[]any{[]string{"c", "d"}, []string{"e", "f"}},
[][]string{
{"a", "b"},
{"c", "d"},
{"e", "f"},
},
},
{[][]string{{"a", "b"}},
{
[][]string{{"a", "b"}},
[]any{[]int{1, 2}},
false,
},
Expand All @@ -130,7 +133,6 @@ func TestAppendToMultiDimensionalSlice(t *testing.T) {
c.Assert(result, qt.DeepEquals, test.expected)
}
}

}

func TestAppendShouldMakeACopyOfTheInputSlice(t *testing.T) {
Expand Down
1 change: 0 additions & 1 deletion common/collections/slice.go
Expand Up @@ -73,7 +73,6 @@ func StringSliceToInterfaceSlice(ss []string) []any {
result[i] = s
}
return result

}

type SortedStringSlice []string
Expand Down
1 change: 0 additions & 1 deletion common/collections/slice_test.go
Expand Up @@ -135,5 +135,4 @@ func TestSortedStringSlice(t *testing.T) {
c.Assert(s.Count("b"), qt.Equals, 3)
c.Assert(s.Count("z"), qt.Equals, 0)
c.Assert(s.Count("a"), qt.Equals, 1)

}
6 changes: 2 additions & 4 deletions common/hexec/exec.go
Expand Up @@ -19,11 +19,10 @@ import (
"errors"
"fmt"
"io"
"regexp"
"strings"

"os"
"os/exec"
"regexp"
"strings"

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

return cm.command(arg...)

}

// Npx is a convenience method to create a Runner running npx --no-install <name> <args.
Expand Down
4 changes: 0 additions & 4 deletions common/htime/time_test.go
Expand Up @@ -53,7 +53,6 @@ func TestTimeFormatter(t *testing.T) {
c.Assert(f.Format(june06, ":time_long"), qt.Equals, "02:09:37 UTC")
c.Assert(f.Format(june06, ":time_medium"), qt.Equals, "02:09:37")
c.Assert(f.Format(june06, ":time_short"), qt.Equals, "02:09")

})

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

})

c.Run("English", func(c *qt.C) {
Expand Down Expand Up @@ -107,9 +105,7 @@ func TestTimeFormatter(t *testing.T) {
c.Assert(tr.MonthWide(date.Month()), qt.Equals, monthWideNorway)
c.Assert(f.Format(date, "January"), qt.Equals, monthWideNorway)
}

})

}

func BenchmarkTimeFormatter(b *testing.B) {
Expand Down
1 change: 0 additions & 1 deletion common/maps/maps_test.go
Expand Up @@ -192,5 +192,4 @@ func TestLookupEqualFold(t *testing.T) {
v, found = LookupEqualFold(m2, "b")
c.Assert(found, qt.IsTrue)
c.Assert(v, qt.Equals, "bv")

}
1 change: 0 additions & 1 deletion common/maps/params_test.go
Expand Up @@ -154,7 +154,6 @@ func TestParamsSetAndMerge(t *testing.T) {
"a": "av",
"c": "cv",
})

}

func TestParamsIsZero(t *testing.T) {
Expand Down
1 change: 0 additions & 1 deletion common/paths/url.go
Expand Up @@ -163,7 +163,6 @@ func Uglify(in string) string {
// If ParseRequestURI fails, the input is just converted to OS specific slashes and returned.
func UrlToFilename(s string) (string, bool) {
u, err := url.ParseRequestURI(s)

if err != nil {
return filepath.FromSlash(s), false
}
Expand Down
4 changes: 0 additions & 4 deletions common/text/transform_test.go
Expand Up @@ -57,7 +57,6 @@ line 3`
c := qt.New(t)

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

}

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

for i := 0; i < b.N; i++ {
VisitLinesAfter(lines, func(s string) {

})

}

}
1 change: 0 additions & 1 deletion common/types/convert.go
Expand Up @@ -80,7 +80,6 @@ func ToStringSlicePreserveStringE(v any) ([]string, error) {
default:
return nil, fmt.Errorf("failed to convert %T to a string slice", v)
}

}

// TypeToString converts v to a string if it's a valid string type.
Expand Down
1 change: 0 additions & 1 deletion common/types/convert_test.go
Expand Up @@ -45,5 +45,4 @@ func TestToDuration(t *testing.T) {
c.Assert(ToDuration("200"), qt.Equals, 200*time.Millisecond)
c.Assert(ToDuration("4m"), qt.Equals, 4*time.Minute)
c.Assert(ToDuration("asdfadf"), qt.Equals, time.Duration(0))

}
1 change: 0 additions & 1 deletion compare/compare_strings_test.go
Expand Up @@ -79,5 +79,4 @@ func BenchmarkStringSort(b *testing.B) {
})
}
})

}
2 changes: 1 addition & 1 deletion config/allconfig/load_test.go
Expand Up @@ -50,7 +50,7 @@ weight = 3
title = "Svenska"
weight = 4
`
if err := os.WriteFile(configFilename, []byte(config), 0666); err != nil {
if err := os.WriteFile(configFilename, []byte(config), 0o666); err != nil {
b.Fatal(err)
}
d := ConfigSourceDescriptor{
Expand Down
1 change: 0 additions & 1 deletion config/configLoader.go
Expand Up @@ -208,7 +208,6 @@ func LoadConfigFromDir(sourceFs afero.Fs, configDir, environment string) (Provid
}

return cfg, dirnames, nil

}

var keyAliases maps.KeyRenamer
Expand Down
1 change: 0 additions & 1 deletion config/defaultConfigProvider.go
Expand Up @@ -370,7 +370,6 @@ func (c *defaultConfigProvider) SetDefaultMergeStrategy() {
}
return false
})

}

func (c *defaultConfigProvider) getNestedKeyAndMap(key string, create bool) (string, maps.Params) {
Expand Down
1 change: 0 additions & 1 deletion config/env.go
Expand Up @@ -49,7 +49,6 @@ func GetMemoryLimit() uint64 {
if v := stringToGibabyte(mem); v > 0 {
return v
}

}

// There is a FreeMemory function, but as the kernel in most situations
Expand Down
1 change: 0 additions & 1 deletion config/security/whitelist_test.go
Expand Up @@ -43,5 +43,4 @@ func TestWhitelist(t *testing.T) {
c.Assert(w.Accept("bar"), qt.IsTrue)
c.Assert(w.Accept("mbar"), qt.IsFalse)
})

}
4 changes: 1 addition & 3 deletions deploy/deployConfig.go
Expand Up @@ -14,11 +14,10 @@
package deploy

import (
"errors"
"fmt"
"regexp"

"errors"

"github.com/gobwas/glob"
"github.com/gohugoio/hugo/config"
hglob "github.com/gohugoio/hugo/hugofs/glob"
Expand Down Expand Up @@ -132,7 +131,6 @@ var DefaultConfig = DeployConfig{

// DecodeConfig creates a config from a given Hugo configuration.
func DecodeConfig(cfg config.Provider) (DeployConfig, error) {

dcfg := DefaultConfig

if !cfg.IsSet(deploymentConfigKey) {
Expand Down
2 changes: 0 additions & 2 deletions htesting/test_helpers_test.go
Expand Up @@ -20,12 +20,10 @@ import (
)

func TestExtractMinorVersionFromGoTag(t *testing.T) {

c := qt.New(t)

c.Assert(extractMinorVersionFromGoTag("go1.17"), qt.Equals, 17)
c.Assert(extractMinorVersionFromGoTag("go1.16.7"), qt.Equals, 16)
c.Assert(extractMinorVersionFromGoTag("go1.17beta1"), qt.Equals, 17)
c.Assert(extractMinorVersionFromGoTag("asdfadf"), qt.Equals, -1)

}
4 changes: 1 addition & 3 deletions hugofs/createcounting_fs.go
Expand Up @@ -33,9 +33,7 @@ type DuplicatesReporter interface {
ReportDuplicates() string
}

var (
_ FilesystemUnwrapper = (*createCountingFs)(nil)
)
var _ FilesystemUnwrapper = (*createCountingFs)(nil)

func NewCreateCountingFs(fs afero.Fs) afero.Fs {
return &createCountingFs{Fs: fs, fileCount: make(map[string]int)}
Expand Down
1 change: 0 additions & 1 deletion hugofs/glob/glob_test.go
Expand Up @@ -75,7 +75,6 @@ func TestGetGlob(t *testing.T) {
}

func BenchmarkGetGlob(b *testing.B) {

runBench := func(name string, cache *globCache, search string) {
b.Run(name, func(b *testing.B) {
g, err := GetGlob("**/foo")
Expand Down
4 changes: 2 additions & 2 deletions hugolib/404_test.go
Expand Up @@ -41,8 +41,8 @@ Data: {{ len .Data }}|
IntegrationTestConfig{
T: t,
TxtarString: files,
//LogLevel: logg.LevelTrace,
//Verbose: true,
// LogLevel: logg.LevelTrace,
// Verbose: true,
},
).Build()

Expand Down
7 changes: 3 additions & 4 deletions hugolib/config.go
Expand Up @@ -157,7 +157,7 @@ module github.com/bep/mymod

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

fs := afero.NewOsFs()

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

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

Expand All @@ -181,5 +181,4 @@ module github.com/bep/mymod
return nil, err
}
return conf.Base, err

}
4 changes: 1 addition & 3 deletions hugolib/language_test.go
Expand Up @@ -26,7 +26,7 @@ import (
func TestI18n(t *testing.T) {
c := qt.New(t)

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

menus := b.H.Sites[0].Menus()
c.Assert(menus, qt.HasLen, 1)

})
}

func TestLanguageNumberFormatting(t *testing.T) {

b := newTestSitesBuilder(t)
b.WithConfigFile("toml", `
baseURL = "https://example.org"
Expand Down
3 changes: 0 additions & 3 deletions langs/language_test.go
Expand Up @@ -23,7 +23,6 @@ import (
)

func TestCollator(t *testing.T) {

c := qt.New(t)

var wg sync.WaitGroup
Expand All @@ -43,7 +42,6 @@ func TestCollator(t *testing.T) {
}()
}
wg.Wait()

}

func BenchmarkCollator(b *testing.B) {
Expand Down Expand Up @@ -75,5 +73,4 @@ func BenchmarkCollator(b *testing.B) {
}
})
})

}
1 change: 0 additions & 1 deletion lazy/init_test.go
Expand Up @@ -234,5 +234,4 @@ func TestResetError(t *testing.T) {
r = true
_, err = i.Do(context.Background())
c.Assert(err, qt.IsNil)

}

0 comments on commit a795acb

Please sign in to comment.