mirror of https://github.com/rwxrob/bonzai
You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
22 lines
348 B
Go
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
|
|
}
|