Skip to content

Commit

Permalink
using slices.IndexFunc
Browse files Browse the repository at this point in the history
  • Loading branch information
cuiweixie committed Mar 30, 2024
1 parent f3b49d4 commit a7ae065
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions cmd/flags.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ package cmd
import (
"fmt"
"math"
"slices"
"strings"

"github.com/prysmaticlabs/prysm/v5/config/params"
Expand Down Expand Up @@ -323,10 +324,10 @@ func ValidateNoArgs(ctx *cli.Context) error {

// verifies that the provided command is in the command list.
func checkCommandList(commands []*cli.Command, name string) *cli.Command {
for _, c := range commands {
if c.Name == name {
return c
}
if i := slices.IndexFunc(commands, func(c *cli.Command) bool {
return c.Name == name
}); i >= 0 {
return commands[i]
}
return nil
}
Expand Down

0 comments on commit a7ae065

Please sign in to comment.