go filters

2026-08-30 浏览 (1)

filters.go 源码

// Copyright © 2018 Inanc Gumus
// Learn Go Programming Course
// License: https://creativecommons.org/licenses/by-nc-sa/4.0/
//
// For more tutorials  : https://learngoprogramming.com
// In-person training  : https://www.linkedin.com/in/inancgumus/
// Follow me on twitter: https://twitter.com/inancgumus

package main

import "strings"

func noopFilter(r result) bool {
	return true
}

func notUsing(filter filterFn) filterFn {
	return func(r result) bool {
		return !filter(r)
	}
}

func domainExtFilter(domains ...string) filterFn {
	return func(r result) bool {
		for _, domain := range domains {
			if strings.HasSuffix(r.domain, "."+domain) {
				return true
			}
		}
		return false
	}
}

func domainFilter(domain string) filterFn {
	return func(r result) bool {
		return strings.Contains(r.domain, domain)
	}
}

func orgDomainsFilter(r result) bool {
	return strings.HasSuffix(r.domain, ".org")
}

你可能感兴趣的文章

go textreader

go result

go chartwriter

go field

go main

go pipeline

go groupers

go textwriter

  • 所属分类: 后端技术
  • 本文标签: golang
  • 版权声明: 本文链接 https://seaxiang.com/blog/GYtK04dn