Skip to content

Commit 2406c8c

Browse files
authored
Merge pull request #3584 from tonistiigi/go1.25-lint
update linters for go1.25 base version
2 parents ef0a7b3 + c5154b3 commit 2406c8c

File tree

30 files changed

+76
-77
lines changed

30 files changed

+76
-77
lines changed

.golangci.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,9 @@ linters:
8787
- linters:
8888
- revive
8989
text: stutters
90+
- linters:
91+
- revive
92+
text: var-naming
9093
- linters:
9194
- revive
9295
text: empty-block

bake/hclparser/gohcl/schema.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -140,11 +140,11 @@ func getFieldTags(ty reflect.Type) *fieldTags {
140140
continue
141141
}
142142

143-
comma := strings.Index(tag, ",")
143+
before, after, ok := strings.Cut(tag, ",")
144144
var name, kind string
145-
if comma != -1 {
146-
name = tag[:comma]
147-
kind = tag[comma+1:]
145+
if ok {
146+
name = before
147+
kind = after
148148
} else {
149149
name = tag
150150
kind = "attr"

bake/hclparser/gohcl/types.go

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,8 @@ import (
99
"github.com/hashicorp/hcl/v2"
1010
)
1111

12-
var victimExpr hcl.Expression
13-
var victimBody hcl.Body
14-
15-
var exprType = reflect.TypeOf(&victimExpr).Elem()
16-
var bodyType = reflect.TypeOf(&victimBody).Elem()
17-
var blockType = reflect.TypeOf((*hcl.Block)(nil)) //nolint:unused
18-
var attrType = reflect.TypeOf((*hcl.Attribute)(nil))
19-
var attrsType = reflect.TypeOf(hcl.Attributes(nil))
12+
var exprType = reflect.TypeFor[hcl.Expression]()
13+
var bodyType = reflect.TypeFor[hcl.Body]()
14+
var blockType = reflect.TypeFor[*hcl.Block]() //nolint:unused
15+
var attrType = reflect.TypeFor[*hcl.Attribute]()
16+
var attrsType = reflect.TypeFor[hcl.Attributes]()

bake/hclparser/stdlib_test.go

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,6 @@ func TestIndexOf(t *testing.T) {
3434
}
3535

3636
for name, test := range tests {
37-
name, test := name, test
3837
t.Run(name, func(t *testing.T) {
3938
got, err := indexOfFunc().Call([]cty.Value{test.input, test.key})
4039
if test.wantErr {
@@ -85,7 +84,6 @@ func TestBasename(t *testing.T) {
8584
}
8685

8786
for name, test := range tests {
88-
name, test := name, test
8987
t.Run(name, func(t *testing.T) {
9088
got, err := basenameFunc().Call([]cty.Value{test.input})
9189
if test.wantErr {
@@ -136,7 +134,6 @@ func TestDirname(t *testing.T) {
136134
}
137135

138136
for name, test := range tests {
139-
name, test := name, test
140137
t.Run(name, func(t *testing.T) {
141138
got, err := dirnameFunc().Call([]cty.Value{test.input})
142139
if test.wantErr {
@@ -190,7 +187,6 @@ func TestSanitize(t *testing.T) {
190187
}
191188

192189
for name, test := range tests {
193-
name, test := name, test
194190
t.Run(name, func(t *testing.T) {
195191
got, err := sanitizeFunc().Call([]cty.Value{test.input})
196192
require.NoError(t, err)
@@ -251,7 +247,6 @@ func TestSemverCmp(t *testing.T) {
251247
},
252248
}
253249
for name, test := range tests {
254-
name, test := name, test
255250
t.Run(name, func(t *testing.T) {
256251
got, err := semvercmpFunc().Call([]cty.Value{test.version, test.constraint})
257252
if test.wantErr {

bake/hclparser/type_implied.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -133,8 +133,8 @@ func impliedStructType(rt reflect.Type, path cty.Path) (cty.Type, error) {
133133
}
134134

135135
var (
136-
valueType = reflect.TypeOf(cty.Value{})
137-
stringType = reflect.TypeOf("")
136+
valueType = reflect.TypeFor[cty.Value]()
137+
stringType = reflect.TypeFor[string]()
138138
)
139139

140140
// structTagIndices interrogates the fields of the given type (which must

build/build.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -395,7 +395,6 @@ func BuildWithResultHandler(ctx context.Context, nodes []builder.Node, opts map[
395395
var insecurePush bool
396396

397397
for i, dp := range dps {
398-
i, dp := i, dp
399398
node := dp.Node()
400399
so := reqForNodes[k][i].so
401400
if multiDriver {

build/resolver/driver.go

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,6 @@ func (r *nodeResolver) Resolve(ctx context.Context, optPlatforms map[string][]oc
131131
eg, egCtx := errgroup.WithContext(ctx)
132132
workers := make([][]ocispecs.Platform, len(clients))
133133
for i, c := range clients {
134-
i, c := i, c
135134
if c == nil {
136135
continue
137136
}
@@ -269,7 +268,6 @@ func (r *nodeResolver) boot(ctx context.Context, idxs []int, pw progress.Writer)
269268
eg, ctx := errgroup.WithContext(ctx)
270269

271270
for i, idx := range idxs {
272-
i, idx := i, idx
273271
eg.Go(func() error {
274272
c, err := r.clients.g.Do(ctx, fmt.Sprint(idx), func(ctx context.Context) (*client.Client, error) {
275273
if r.nodes[idx].Driver == nil {

commands/dap.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,8 @@ func dapAttachCmd() *cobra.Command {
102102
return err
103103
}
104104

105-
conn, err := net.Dial("unix", args[0])
105+
dialer := net.Dialer{}
106+
conn, err := dialer.DialContext(cmd.Context(), "unix", args[0])
106107
if err != nil {
107108
return err
108109
}

commands/history/trace.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -156,7 +156,8 @@ func runTrace(ctx context.Context, dockerCli command.Cli, opts traceOptions) err
156156
return nil
157157
}
158158

159-
ln, err := net.Listen("tcp", opts.addr)
159+
lc := net.ListenConfig{}
160+
ln, err := lc.Listen(ctx, "tcp", opts.addr)
160161
if err != nil {
161162
return err
162163
}

commands/history/utils.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -425,8 +425,8 @@ func timeBasedFilter(key, value, sep string) (matchFunc, error) {
425425

426426
func cutAny(s string, seps ...string) (before, after, sep string, found bool) {
427427
for _, sep := range seps {
428-
if idx := strings.Index(s, sep); idx != -1 {
429-
return s[:idx], s[idx+len(sep):], sep, true
428+
if before0, after0, ok := strings.Cut(s, sep); ok {
429+
return before0, after0, sep, true
430430
}
431431
}
432432
return s, "", "", false

0 commit comments

Comments
 (0)