Skip to content

Commit b470f22

Browse files
committed
fix lint errors detected by golangci-lint v2.11.4
Fix modernize issues in cmd/controller/main.go and a prealloc issue in test/e2e/singlek8s/util.go. Signed-off-by: Kohya Shiozaki <kouyan120706@gmail.com>
1 parent 33650ed commit b470f22

2 files changed

Lines changed: 9 additions & 13 deletions

File tree

cmd/controller/main.go

Lines changed: 6 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -410,12 +410,10 @@ func setupPrimary(ctx context.Context, mgr manager.Manager, wg *sync.WaitGroup)
410410
return err
411411
}
412412

413-
wg.Add(1)
414-
go func() {
415-
defer wg.Done()
413+
wg.Go(func() {
416414
<-ctx.Done()
417415
_ = conn.Close()
418-
}()
416+
})
419417

420418
primarySettings := &controller.PrimarySettings{
421419
ServiceEndpoint: mantleServiceEndpoint,
@@ -467,22 +465,18 @@ func setupSecondary(ctx context.Context, mgr manager.Manager, wg *sync.WaitGroup
467465
return fmt.Errorf("failed to listen %s: %w", mantleServiceEndpoint, err)
468466
}
469467

470-
wg.Add(1)
471-
go func() {
472-
defer wg.Done()
468+
wg.Go(func() {
473469
err := serv.Serve(l)
474470
if err != nil {
475471
logger.Error(err, "gRPC server failed")
476472
}
477473
cancel()
478-
}()
474+
})
479475

480-
wg.Add(1)
481-
go func() {
482-
defer wg.Done()
476+
wg.Go(func() {
483477
<-ctx.Done()
484478
serv.GracefulStop()
485-
}()
479+
})
486480

487481
return setupReconcilers(mgr, nil, &controller.SecondarySettings{
488482
MaxImportJobs: maxImportJobs,

test/e2e/singlek8s/util.go

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -517,7 +517,9 @@ func getImageAndSnapNames(namespace, pool string) ([]string, error) {
517517
}
518518
}
519519

520-
return append(images, snaps...), nil
520+
result := make([]string, 0, len(images)+len(snaps))
521+
522+
return append(append(result, images...), snaps...), nil
521523
}
522524

523525
func checkJobExists(namespace, jobName string) (bool, error) {

0 commit comments

Comments
 (0)