Skip to content

Commit

Permalink
using slices.IndexFunc (#13839)
Browse files Browse the repository at this point in the history
  • Loading branch information
cuiweixie authored Apr 2, 2024
1 parent d1084cb commit 7bce1c0
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 7bce1c0

Please sign in to comment.