Skip to content

Commit 7df46a9

Browse files
author
taofzen
committed
refactor: replace HasSuffix+TrimSuffix with CutSuffix
Signed-off-by: taofzen <taofzen@outlook.com>
1 parent 205f4ee commit 7df46a9

1 file changed

Lines changed: 1 addition & 2 deletions

File tree

rocketpool-cli/node/commands.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -365,8 +365,7 @@ func RegisterCommands(app *cli.Command, name string, aliases []string) {
365365
// Validate flags
366366
amount := c.String("amount")
367367
if amount != "" {
368-
if strings.HasSuffix(amount, "%") {
369-
trimmedAmount := strings.TrimSuffix(amount, "%")
368+
if trimmedAmount, ok := strings.CutSuffix(amount, "%"); ok {
370369
stakePercent, err := strconv.ParseFloat(trimmedAmount, 64)
371370
if err != nil || stakePercent <= 0 {
372371
return fmt.Errorf("invalid percentage value: %s", amount)

0 commit comments

Comments
 (0)