gobstore/filter.go

17 lines
304 B
Go
Raw Permalink Normal View History

2025-01-12 09:51:51 +00:00
package gobstore
import "strings"
// Filter performs a prefix match against all key values.
func (j *GobStore[T]) Filter(prefix string) []T {
j.Lock()
defer j.Unlock()
res := make([]T, 0)
for k, v := range j.values {
if strings.HasPrefix(k, prefix) {
res = append(res, v)
}
}
return res
}