Skip to content

Commit e310822

Browse files
committed
all: Run go fix ./...
1 parent c9b88e4 commit e310822

Some content is hidden

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

44 files changed

+205
-187
lines changed

codegen/methods.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ func (c *Inspector) MethodsFromTypes(include []reflect.Type, exclude []reflect.T
7373
nameAndPackage := func(t reflect.Type) (string, string) {
7474
var name, pkg string
7575

76-
isPointer := t.Kind() == reflect.Ptr
76+
isPointer := t.Kind() == reflect.Pointer
7777

7878
if isPointer {
7979
t = t.Elem()

codegen/methods_test.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,9 +26,9 @@ import (
2626

2727
func TestMethods(t *testing.T) {
2828
var (
29-
zeroIE = reflect.TypeOf((*IEmbed)(nil)).Elem()
30-
zeroIEOnly = reflect.TypeOf((*IEOnly)(nil)).Elem()
31-
zeroI = reflect.TypeOf((*I)(nil)).Elem()
29+
zeroIE = reflect.TypeFor[IEmbed]()
30+
zeroIEOnly = reflect.TypeFor[IEOnly]()
31+
zeroI = reflect.TypeFor[I]()
3232
)
3333

3434
dir, _ := os.Getwd()

common/hashing/hashing_test.go

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -38,9 +38,7 @@ func TestXxHashFromReaderPara(t *testing.T) {
3838

3939
var wg sync.WaitGroup
4040
for i := range 10 {
41-
wg.Add(1)
42-
go func() {
43-
defer wg.Done()
41+
wg.Go(func() {
4442
for j := range 100 {
4543
s := strings.Repeat("Hello ", i+j+1*42)
4644
r := strings.NewReader(s)
@@ -50,7 +48,7 @@ func TestXxHashFromReaderPara(t *testing.T) {
5048
expect, _ := XXHashFromString(s)
5149
c.Assert(got, qt.Equals, expect)
5250
}
53-
}()
51+
})
5452
}
5553

5654
wg.Wait()

common/herrors/file_error_test.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,15 +32,15 @@ func TestNewFileError(t *testing.T) {
3232
fe := NewFileErrorFromName(errors.New("bar"), "foo.html")
3333
c.Assert(fe.Error(), qt.Equals, `"foo.html:1:1": bar`)
3434

35-
lines := ""
35+
var lines strings.Builder
3636
for i := 1; i <= 100; i++ {
37-
lines += fmt.Sprintf("line %d\n", i)
37+
lines.WriteString(fmt.Sprintf("line %d\n", i))
3838
}
3939

4040
fe.UpdatePosition(text.Position{LineNumber: 32, ColumnNumber: 2})
4141
c.Assert(fe.Error(), qt.Equals, `"foo.html:32:2": bar`)
4242
fe.UpdatePosition(text.Position{LineNumber: 0, ColumnNumber: 0, Offset: 212})
43-
fe.UpdateContent(strings.NewReader(lines), nil)
43+
fe.UpdateContent(strings.NewReader(lines.String()), nil)
4444
c.Assert(fe.Error(), qt.Equals, `"foo.html:32:0": bar`)
4545
errorContext := fe.ErrorContext()
4646
c.Assert(errorContext, qt.IsNotNil)

common/hreflect/convert.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ func errConvert(v reflect.Value, s string) error {
9696
// See Issue 14079.
9797
func ConvertIfPossible(val reflect.Value, typ reflect.Type) (reflect.Value, bool) {
9898
switch val.Kind() {
99-
case reflect.Ptr, reflect.Interface:
99+
case reflect.Pointer, reflect.Interface:
100100
if val.IsNil() {
101101
// Return typ's zero value.
102102
return reflect.Zero(typ), true

common/hreflect/helpers.go

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ import (
2727

2828
// IsInterfaceOrPointer returns whether the given kind is an interface or a pointer.
2929
func IsInterfaceOrPointer(kind reflect.Kind) bool {
30-
return kind == reflect.Interface || kind == reflect.Ptr
30+
return kind == reflect.Interface || kind == reflect.Pointer
3131
}
3232

3333
// TODO(bep) replace the private versions in /tpl with these.
@@ -92,7 +92,7 @@ func IsSlice(v any) bool {
9292
return reflect.ValueOf(v).Kind() == reflect.Slice
9393
}
9494

95-
var zeroType = reflect.TypeOf((*types.Zeroer)(nil)).Elem()
95+
var zeroType = reflect.TypeFor[types.Zeroer]()
9696

9797
var isZeroCache sync.Map
9898

@@ -136,7 +136,7 @@ func IsTruthfulValue(val reflect.Value) (truth bool) {
136136
truth = val.Bool()
137137
case reflect.Complex64, reflect.Complex128:
138138
truth = val.Complex() != 0
139-
case reflect.Chan, reflect.Func, reflect.Ptr, reflect.Interface:
139+
case reflect.Chan, reflect.Func, reflect.Pointer, reflect.Interface:
140140
truth = !val.IsNil()
141141
case reflect.Int, reflect.Int8, reflect.Int16, reflect.Int32, reflect.Int64:
142142
truth = val.Int() != 0
@@ -216,8 +216,8 @@ func GetMethodIndexByName(tp reflect.Type, name string) int {
216216
}
217217

218218
var (
219-
timeType = reflect.TypeOf((*time.Time)(nil)).Elem()
220-
asTimeProviderType = reflect.TypeOf((*htime.AsTimeProvider)(nil)).Elem()
219+
timeType = reflect.TypeFor[time.Time]()
220+
asTimeProviderType = reflect.TypeFor[htime.AsTimeProvider]()
221221
)
222222

223223
// IsTime returns whether tp is a time.Time type or if it can be converted into one
@@ -240,7 +240,7 @@ func IsValid(v reflect.Value) bool {
240240
}
241241

242242
switch v.Kind() {
243-
case reflect.Chan, reflect.Func, reflect.Interface, reflect.Map, reflect.Ptr, reflect.Slice:
243+
case reflect.Chan, reflect.Func, reflect.Interface, reflect.Map, reflect.Pointer, reflect.Slice:
244244
return !v.IsNil()
245245
}
246246

@@ -347,13 +347,13 @@ func IsNil(v reflect.Value) bool {
347347
return true
348348
}
349349
switch v.Kind() {
350-
case reflect.Chan, reflect.Func, reflect.Interface, reflect.Map, reflect.Ptr, reflect.Slice:
350+
case reflect.Chan, reflect.Func, reflect.Interface, reflect.Map, reflect.Pointer, reflect.Slice:
351351
return v.IsNil()
352352
}
353353
return false
354354
}
355355

356-
var contextInterface = reflect.TypeOf((*context.Context)(nil)).Elem()
356+
var contextInterface = reflect.TypeFor[context.Context]()
357357

358358
var isContextCache = hmaps.NewCache[reflect.Type, bool]()
359359

common/types/evictingqueue_test.go

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -56,9 +56,7 @@ func TestEvictingStringQueueConcurrent(t *testing.T) {
5656
queue := NewEvictingQueue[string](3)
5757

5858
for range 100 {
59-
wg.Add(1)
60-
go func() {
61-
defer wg.Done()
59+
wg.Go(func() {
6260
queue.Add(val)
6361
v := queue.Peek()
6462
if v != val {
@@ -68,7 +66,7 @@ func TestEvictingStringQueueConcurrent(t *testing.T) {
6866
if len(vals) != 1 || vals[0] != val {
6967
t.Error("wrong val")
7068
}
71-
}()
69+
})
7270
}
7371
wg.Wait()
7472
}

common/types/types.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ func IsNil(v any) bool {
8989

9090
value := reflect.ValueOf(v)
9191
switch value.Kind() {
92-
case reflect.Chan, reflect.Func, reflect.Interface, reflect.Map, reflect.Ptr, reflect.Slice:
92+
case reflect.Chan, reflect.Func, reflect.Interface, reflect.Map, reflect.Pointer, reflect.Slice:
9393
return value.IsNil()
9494
}
9595

config/security/securityConfig.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -202,7 +202,7 @@ func stringSliceToWhitelistHook() mapstructure.DecodeHookFuncType {
202202
t reflect.Type,
203203
data any,
204204
) (any, error) {
205-
if t != reflect.TypeOf(Whitelist{}) {
205+
if t != reflect.TypeFor[Whitelist]() {
206206
return data, nil
207207
}
208208

helpers/path.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -109,13 +109,13 @@ func GetDottedRelativePath(inPath string) string {
109109
return "./"
110110
}
111111

112-
var dottedPath string
112+
var dottedPath strings.Builder
113113

114114
for i := 1; i < sectionCount; i++ {
115-
dottedPath += "../"
115+
dottedPath.WriteString("../")
116116
}
117117

118-
return dottedPath
118+
return dottedPath.String()
119119
}
120120

121121
type NamedSlice struct {

0 commit comments

Comments
 (0)