Skip to content

Commit d90e37e

Browse files
committed
all: Format code with gofumpt
See https://github.com/mvdan/gofumpt
1 parent 32471b5 commit d90e37e

File tree

442 files changed

+1423
-2251
lines changed

Some content is hidden

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

442 files changed

+1423
-2251
lines changed

cache/filecache/filecache.go

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -158,7 +158,6 @@ func (c *Cache) ReadOrCreate(id string,
158158
err = create(info, f)
159159

160160
return
161-
162161
}
163162

164163
// GetOrCreate tries to get the file with the given id from cache. If not found or expired, create will
@@ -220,7 +219,6 @@ func (c *Cache) GetOrCreateBytes(id string, create func() ([]byte, error)) (Item
220219
return info, nil, err
221220
}
222221
return info, b, nil
223-
224222
}
225223

226224
// GetBytes gets the file content with the given id from the cahce, nil if none found.
@@ -276,7 +274,6 @@ func (c *Cache) getOrRemove(id string) hugio.ReadSeekCloser {
276274
}
277275

278276
f, err := c.Fs.Open(id)
279-
280277
if err != nil {
281278
return nil
282279
}
@@ -299,15 +296,13 @@ func (c *Cache) getString(id string) string {
299296
defer c.nlocker.Unlock(id)
300297

301298
f, err := c.Fs.Open(id)
302-
303299
if err != nil {
304300
return ""
305301
}
306302
defer f.Close()
307303

308304
b, _ := ioutil.ReadAll(f)
309305
return string(b)
310-
311306
}
312307

313308
// Caches is a named set of caches.

cache/filecache/filecache_config_test.go

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,6 @@ dir = "/path/to/c3"
6969
c3 := decoded["images"]
7070
c.Assert(c3.MaxAge, qt.Equals, time.Duration(-1))
7171
c.Assert(c3.Dir, qt.Equals, filepath.FromSlash("/path/to/c3/filecache/images"))
72-
7372
}
7473

7574
func TestDecodeConfigIgnoreCache(t *testing.T) {
@@ -110,7 +109,6 @@ dir = "/path/to/c3"
110109
for _, v := range decoded {
111110
c.Assert(v.MaxAge, qt.Equals, time.Duration(0))
112111
}
113-
114112
}
115113

116114
func TestDecodeConfigDefault(t *testing.T) {
@@ -178,7 +176,6 @@ dir = "/"
178176

179177
_, err = DecodeConfig(fs, cfg)
180178
c.Assert(err, qt.Not(qt.IsNil))
181-
182179
}
183180

184181
func newTestConfig() *viper.Viper {

cache/filecache/filecache_pruner.go

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,6 @@ func (c *Cache) Prune(force bool) (int, error) {
110110
}
111111

112112
func (c *Cache) pruneRootDir(force bool) (int, error) {
113-
114113
info, err := c.Fs.Stat(c.pruneAllRootDir)
115114
if err != nil {
116115
if os.IsNotExist(err) {
@@ -124,5 +123,4 @@ func (c *Cache) pruneRootDir(force bool) (int, error) {
124123
}
125124

126125
return hugofs.MakeReadableAndRemoveAllModulePkgDir(c.Fs, c.pruneAllRootDir)
127-
128126
}

cache/filecache/filecache_pruner_test.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -107,5 +107,4 @@ dir = ":resourceDir/_gen"
107107
}
108108

109109
}
110-
111110
}

cache/filecache/filecache_test.go

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -183,7 +183,6 @@ dir = ":cacheDir/c"
183183
c.Assert(string(b), qt.Equals, "Hugo is great!")
184184

185185
}
186-
187186
}
188187

189188
func TestFileCacheConcurrent(t *testing.T) {
@@ -253,7 +252,6 @@ func TestFileCacheReadOrCreateErrorInRead(t *testing.T) {
253252
var result string
254253

255254
rf := func(failLevel int) func(info ItemInfo, r io.ReadSeeker) error {
256-
257255
return func(info ItemInfo, r io.ReadSeeker) error {
258256
if failLevel > 0 {
259257
if failLevel > 1 {
@@ -347,5 +345,4 @@ func newPathsSpec(t *testing.T, fs afero.Fs, configStr string) *helpers.PathSpec
347345
p, err := helpers.NewPathSpec(hugofs.NewFrom(fs, cfg), cfg, nil)
348346
c.Assert(err, qt.IsNil)
349347
return p
350-
351348
}

cache/namedmemcache/named_cache.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,6 @@ func (c *Cache) Clear() {
4949

5050
c.cache = make(map[string]cacheEntry)
5151
c.nlocker = locker.NewLocker()
52-
5352
}
5453

5554
// GetOrCreate tries to get the value with the given cache key, if not found

codegen/methods.go

Lines changed: 2 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ func (c *Inspector) MethodsFromTypes(include []reflect.Type, exclude []reflect.T
5858

5959
var methods Methods
6060

61-
var excludes = make(map[string]bool)
61+
excludes := make(map[string]bool)
6262

6363
if len(exclude) > 0 {
6464
for _, m := range c.MethodsFromTypes(exclude, nil) {
@@ -99,11 +99,9 @@ func (c *Inspector) MethodsFromTypes(include []reflect.Type, exclude []reflect.T
9999
name = pkgPrefix + name
100100

101101
return name, pkg
102-
103102
}
104103

105104
for _, t := range include {
106-
107105
for i := 0; i < t.NumMethod(); i++ {
108106

109107
m := t.Method(i)
@@ -153,7 +151,6 @@ func (c *Inspector) MethodsFromTypes(include []reflect.Type, exclude []reflect.T
153151

154152
methods = append(methods, method)
155153
}
156-
157154
}
158155

159156
sort.SliceStable(methods, func(i, j int) bool {
@@ -167,16 +164,13 @@ func (c *Inspector) MethodsFromTypes(include []reflect.Type, exclude []reflect.T
167164
}
168165

169166
return wi < wj
170-
171167
})
172168

173169
return methods
174-
175170
}
176171

177172
func (c *Inspector) parseSource() {
178173
c.init.Do(func() {
179-
180174
if !strings.Contains(c.ProjectRootDir, "hugo") {
181175
panic("dir must be set to the Hugo root")
182176
}
@@ -200,7 +194,6 @@ func (c *Inspector) parseSource() {
200194
filenames = append(filenames, path)
201195

202196
return nil
203-
204197
})
205198

206199
for _, filename := range filenames {
@@ -230,7 +223,6 @@ func (c *Inspector) parseSource() {
230223
c.methodWeight[iface] = weights
231224
}
232225
}
233-
234226
}
235227
return true
236228
})
@@ -247,7 +239,6 @@ func (c *Inspector) parseSource() {
247239
}
248240
}
249241
}
250-
251242
})
252243
}
253244

@@ -385,7 +376,7 @@ func (m Methods) ToMarshalJSON(receiver, pkgPath string, excludes ...string) (st
385376
fmt.Fprintf(&sb, "func Marshal%sToJSON(%s %s) ([]byte, error) {\n", what, r, receiver)
386377

387378
var methods Methods
388-
var excludeRes = make([]*regexp.Regexp, len(excludes))
379+
excludeRes := make([]*regexp.Regexp, len(excludes))
389380

390381
for i, exclude := range excludes {
391382
excludeRes[i] = regexp.MustCompile(exclude)
@@ -450,7 +441,6 @@ func (m Methods) ToMarshalJSON(receiver, pkgPath string, excludes ...string) (st
450441
}
451442

452443
return sb.String(), pkgImports
453-
454444
}
455445

456446
func collectMethodsRecursive(pkg string, f []*ast.Field) []string {
@@ -481,7 +471,6 @@ func collectMethodsRecursive(pkg string, f []*ast.Field) []string {
481471
}
482472

483473
return methodNames
484-
485474
}
486475

487476
func firstToLower(name string) string {
@@ -544,5 +533,4 @@ func varName(name string) string {
544533
}
545534

546535
return name
547-
548536
}

codegen/methods_test.go

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@ import (
2525
)
2626

2727
func TestMethods(t *testing.T) {
28-
2928
var (
3029
zeroIE = reflect.TypeOf((*IEmbed)(nil)).Elem()
3130
zeroIEOnly = reflect.TypeOf((*IEOnly)(nil)).Elem()
@@ -58,7 +57,6 @@ func TestMethods(t *testing.T) {
5857
methodsStr := fmt.Sprint(methods)
5958

6059
c.Assert(methodsStr, qt.Contains, "MethodEmbed3(arg0 string) string")
61-
6260
})
6361

6462
t.Run("ToMarshalJSON", func(t *testing.T) {
@@ -76,9 +74,7 @@ func TestMethods(t *testing.T) {
7674
c.Assert(pkg, qt.Contains, "encoding/json")
7775

7876
fmt.Println(pkg)
79-
8077
})
81-
8278
}
8379

8480
type I interface {

commands/check.go

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -26,9 +26,10 @@ type checkCmd struct {
2626
}
2727

2828
func newCheckCmd() *checkCmd {
29-
return &checkCmd{baseCmd: &baseCmd{cmd: &cobra.Command{
30-
Use: "check",
31-
Short: "Contains some verification checks",
32-
},
29+
return &checkCmd{baseCmd: &baseCmd{
30+
cmd: &cobra.Command{
31+
Use: "check",
32+
Short: "Contains some verification checks",
33+
},
3334
}}
3435
}

commands/check_darwin.go

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,10 +24,11 @@ type checkCmd struct {
2424
}
2525

2626
func newCheckCmd() *checkCmd {
27-
cc := &checkCmd{baseCmd: &baseCmd{cmd: &cobra.Command{
28-
Use: "check",
29-
Short: "Contains some verification checks",
30-
},
27+
cc := &checkCmd{baseCmd: &baseCmd{
28+
cmd: &cobra.Command{
29+
Use: "check",
30+
Short: "Contains some verification checks",
31+
},
3132
}}
3233

3334
cc.cmd.AddCommand(newLimitCmd().getCommand())

0 commit comments

Comments
 (0)