mirror of
https://github.com/rwxrob/bonzai
synced 2024-11-18 15:25:45 +00:00
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
|
|
}
|