bonzai/filt/filt.go
2022-02-25 21:46:36 -05:00

22 lines
348 B
Go

package filt
import (
"strings"
)
type Text interface {
string | []byte
}
// HasPrefix filters the Text input set and returns only those elements
// that have the give prefix.
func HasPrefix[T Text](set []T, pre string) []T {
m := []T{}
for _, i := range set {
if strings.HasPrefix(string(i), pre) {
m = append(m, i)
}
}
return m
}