filter

package
v0.0.0-...-17ee6b1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 27, 2015 License: BSD-2-Clause Imports: 3 Imported by: 0

Documentation

Overview

Package filter implements filters for files similar to filepath.Glob, but in contrast to filepath.Glob a pattern may specify directories.

For a list of valid patterns please see the documentation on filepath.Glob.

Index

Examples

Constants

This section is empty.

Variables

View Source
var ErrBadString = errors.New("filter.Match: string is empty")

ErrBadString is returned when Match is called with the empty string as the second argument.

Functions

func List

func List(patterns []string, str string) (matched bool, err error)

List returns true if str matches one of the patterns.

func Match

func Match(pattern, str string) (matched bool, err error)

Match returns true if str matches the pattern. When the pattern is malformed, filepath.ErrBadPattern is returned. The empty pattern matches everything, when str is the empty string ErrBadString is returned.

Pattern can be a combination of patterns suitable for filepath.Match, joined by filepath.Separator.

Example
package main

import (
	"fmt"

	"github.com/restic/restic/filter"
)

func main() {
	match, _ := filter.Match("*.go", "/home/user/file.go")
	fmt.Printf("match: %v\n", match)
}
Output:

match: true
Example (Wildcards)
package main

import (
	"fmt"

	"github.com/restic/restic/filter"
)

func main() {
	match, _ := filter.Match("/home/[uU]ser/?.go", "/home/user/F.go")
	fmt.Printf("match: %v\n", match)
}
Output:

match: true

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL