func compileIgnoreRule(rule string) (ignoreRuleEvalFn, error) {
	var (
		negateRule     bool
		applyToDirOnly bool
	)

	// If the rule begins with a '!' then the pattern is negated; any
	// matching file excluded by a previous pattern will become included
	// again.
	if strings.HasPrefix(rule, "!") {
		rule = strings.TrimPrefix(rule, "!")
		negateRule = true
	}

	rule = unescapeIgnorePattern(rule)

	// If the rule ends in a '/' then the slash is stripped off but the
	// rule will only apply to directories.
	if strings.HasSuffix(rule, "/") {
		rule = strings.TrimSuffix(rule, "/")
		applyToDirOnly = true
	}

	// A leading "**" followed by a slash means match in all directories.
	// "**/foo" is equivalent to "foo/bar" so we can actually trim it.
	if strings.HasPrefix(rule, "**/") {
		rule = strings.TrimPrefix(rule, "**/")
	}

	// A leading slash matches the beginning of the pathname. For example,
	// "/*.go" matches "foo.go" but not "bar/foo.go". In all other cases
	// the pattern applies at any location (substring pattern) and we need
	// to prefix it with "**/" (** behaves like * but also matches path
	// separators)
	if !strings.HasPrefix(rule, "/") {
		rule = "**/" + rule
	}

	fn, err := ignoreGlobMatch(rule)
	if err != nil {
		return nil, err
	}

	if applyToDirOnly {
		fn = ignoreOnlyDirs(fn)
	}

	if negateRule {
		fn = negateIgnoreRule(fn)
	}

	return fn, nil
}
// compileIgnoreRule returns an ignoreRuleEvalFn for the provided rule.
compileIgnoreRule returns an ignoreRuleEvalFn for the provided rule.
// compileIgnoreRule returns an ignoreRuleEvalFn for the provided rule .
func compileIgnoreRule(rule string) (ignoreRuleEvalFn, error) {
	var (
		negateRule     bool
		applyToDirOnly bool
	)
	if strings.HasPrefix(rule, "!") {
		rule = strings.TrimPrefix(rule, "!")
		negateRule = true
	}
	rule = unescapeIgnorePattern(rule)
	if strings.HasSuffix(rule, "/") {
		rule = strings.TrimSuffix(rule, "/")
		applyToDirOnly = true
	}
	if strings.HasPrefix(rule, "**/") {
		rule = strings.TrimPrefix(rule, "**/")
	}
	if !strings.HasPrefix(rule, "/") {
		rule = "**/" + rule
	}
	fn, err := ignoreGlobMatch(rule)
	if err != nil {
		return nil, err
	}
	if applyToDirOnly {
		fn = ignoreOnlyDirs(fn)
	}
	if negateRule {
		fn = negateIgnoreRule(fn)
	}
	return fn, nil
}
func compileIgnoreRule ( rule string ) ( ignoreRuleEvalFn , error ) { var ( negateRule bool applyToDirOnly bool ) if strings . HasPrefix ( rule , " " ) { rule = strings . TrimPrefix ( rule , " " ) negateRule = true } rule = unescapeIgnorePattern ( rule ) if strings . HasSuffix ( rule , " " ) { rule = strings . TrimSuffix ( rule , " " ) applyToDirOnly = true } if strings . HasPrefix ( rule , " " ) { rule = strings . TrimPrefix ( rule , " " ) } if ! strings . HasPrefix ( rule , " " ) { rule = " " + rule } fn , err := ignoreGlobMatch ( rule ) if err != nil { return nil , err } if applyToDirOnly { fn = ignoreOnlyDirs ( fn ) } if negateRule { fn = negateIgnoreRule ( fn ) } return fn , nil }
compileIgnoreRule returns an ignoreRuleEvalFn for the provided rule.
compileIgnoreRule returns an ignoreRuleEvalFn for the provided rule .
// If the rule begins with a '!' then the pattern is negated; any // matching file excluded by a previous pattern will become included // again. // If the rule ends in a '/' then the slash is stripped off but the // rule will only apply to directories. // A leading "**" followed by a slash means match in all directories. // "**/foo" is equivalent to "foo/bar" so we can actually trim it. // A leading slash matches the beginning of the pathname. For example, // "/*.go" matches "foo.go" but not "bar/foo.go". In all other cases // the pattern applies at any location (substring pattern) and we need // to prefix it with "**/" (** behaves like * but also matches path // separators)