Skip to content
This repository has been archived by the owner on Dec 8, 2022. It is now read-only.

Commit

Permalink
chore: check slice.Contains in for range (#151)
Browse files Browse the repository at this point in the history
See:

Why:

How:

Tags:

Co-authored-by: Iman Tumorang <iman.tumorang@gmail.com>
  • Loading branch information
eval-exec and bxcodec committed Dec 29, 2021
1 parent 842237f commit e818c6c
Showing 1 changed file with 4 additions and 5 deletions.
9 changes: 4 additions & 5 deletions support/slice/helpers.go
Expand Up @@ -6,13 +6,12 @@ import (

// Contains Check item in slice string type
func Contains(slice []string, item string) bool {
set := make(map[string]struct{}, len(slice))
for _, s := range slice {
set[s] = struct{}{}
if s == item {
return true
}
}

_, ok := set[item]
return ok
return false
}

// ContainsRune Check item in map rune type
Expand Down

0 comments on commit e818c6c

Please sign in to comment.