gopherage/pkg/cov/filter.go
func FilterProfilePaths(profile []*cover.Profile, paths []string, include bool) ([]*cover.Profile, error) {
	parenPaths := make([]string, len(paths))
	for i, path := range paths {
		parenPaths[i] = "(" + path + ")"
	}
	joined := strings.Join(parenPaths, "|")
	re, err := regexp.Compile(joined)
	if err != nil {
		return nil, err
	}
	result := make([]*cover.Profile, 0, len(profile))
	for _, p := range profile {
		if re.MatchString(p.FileName) == include {
			result = append(result, p)
		}
	}
	return result, nil
}
func FilterProfilePaths(profile []*cover.Profile, paths []string, include bool) ([]*cover.Profile, error) {
	parenPaths := make([]string, len(paths))
	for i, path := range paths {
		parenPaths[i] = "(" + path + ")"
	}
	joined := strings.Join(parenPaths, "|")
	re, err := regexp.Compile(joined)
	if err != nil {
		return nil, err
	}
	result := make([]*cover.Profile, 0, len(profile))
	for _, p := range profile {
		if re.MatchString(p.FileName) == include {
			result = append(result, p)
		}
	}
	return result, nil
}
// FilterProfilePaths produces a new profile that removes either everything matching or everything
// not matching the provided paths, depending on the value of include.
// Paths are interpreted as regular expressions.
// If include is true, paths is treated as a whitelist; otherwise it is treated as a blacklist.