17 lines
304 B
Go
17 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
|
||
|
}
|