File: filter.go

package info (click to toggle)
golang-github-jedib0t-go-pretty 6.5.9-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 1,700 kB
  • sloc: makefile: 28; sh: 14
file content (12 lines) | stat: -rw-r--r-- 257 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
package text

// Filter filters the slice 's' to items which return truth when passed to 'f'.
func Filter(s []string, f func(string) bool) []string {
	var out []string
	for _, item := range s {
		if f(item) {
			out = append(out, item)
		}
	}
	return out
}