Skip to content

Commit

Permalink
refactor: using slices.Contains to simplify the code
Browse files Browse the repository at this point in the history
Signed-off-by: damuzhi0810 <[email protected]>
  • Loading branch information
damuzhi0810 committed Jan 23, 2025
1 parent d52e3dd commit 7292e60
Showing 1 changed file with 2 additions and 6 deletions.
8 changes: 2 additions & 6 deletions cmd/goal/accountsList.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ import (
"os"
"os/user"
"path/filepath"
"slices"
"strings"

"github.com/algorand/go-algorand/daemon/algod/api/server/v2/generated/model"
Expand Down Expand Up @@ -101,12 +102,7 @@ func (accountList *AccountsList) setDefault(accountName string) {

// isTaken checks if the account friendly name is already being used by another account
func (accountList *AccountsList) isTaken(accountName string) bool {
for _, name := range accountList.Accounts {
if name == accountName {
return true
}
}
return false
return slices.Contains(accountList.Accounts, accountName)

Check failure on line 105 in cmd/goal/accountsList.go

View workflow job for this annotation

GitHub Actions / build-windows

in call to slices.Contains, S (type map[string]string) does not satisfy ~[]E

Check failure on line 105 in cmd/goal/accountsList.go

View workflow job for this annotation

GitHub Actions / Performance regression check

in call to slices.Contains, S (type map[string]string) does not satisfy ~[]E

Check failure on line 105 in cmd/goal/accountsList.go

View workflow job for this annotation

GitHub Actions / reviewdog-errors

[Lint Errors] reported by reviewdog 🐶 in call to slices.Contains, S (type map[string]string) does not satisfy ~[]E (typecheck) Raw Output: cmd/goal/accountsList.go:105:24: in call to slices.Contains, S (type map[string]string) does not satisfy ~[]E (typecheck) // Copyright (C) 2019-2025 Algorand, Inc.

Check failure on line 105 in cmd/goal/accountsList.go

View workflow job for this annotation

GitHub Actions / reviewdog-warnings

in call to slices.Contains, S (type map[string]string) does not satisfy ~[]E (typecheck)

Check failure on line 105 in cmd/goal/accountsList.go

View workflow job for this annotation

GitHub Actions / reviewdog-warnings

[Lint Warnings] reported by reviewdog 🐶 in call to slices.Contains, S (type map[string]string) does not satisfy ~[]E (typecheck) Raw Output: cmd/goal/accountsList.go:105:24: in call to slices.Contains, S (type map[string]string) does not satisfy ~[]E (typecheck) // Copyright (C) 2019-2025 Algorand, Inc.
}

// rename renames account's friendly name
Expand Down

0 comments on commit 7292e60

Please sign in to comment.