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

chore: check slice.Contains in for range block #151

Merged
merged 2 commits into from Dec 29, 2021
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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