gobstore/filter.go
2025-01-12 02:51:51 -07:00

16 lines
304 B
Go

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
}