filter

package
v0.2.1 Latest Latest
Warning

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

Go to latest
Published: Aug 8, 2022 License: ISC Imports: 9 Imported by: 0

Documentation

Overview

Package filter contains filters for the filesystem.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Consumes

func Consumes(path string, args []string) bool

Consumes filter files that are not in the specified size range.

func Glob

func Glob(path string, args []string) bool

Glob filter files that do not match the specified Unix Shell Glob. In the current implementation, the `*` character also coincides with `.` (dot). If the Glob provided does not contain the `/` character, only the last element of the route provided will be evaluated. In the opposite case, the entire route will be evaluated.

This filter takes exactly one argument.

func Identifier

func Identifier(path string, args []string) bool

Identifier filter files that do not start with the magic number provided.

func MIME added in v0.2.1

func MIME(path string, args []string) bool

MIME filter files that are of the specified type.

func Name

func Name(path string, args []string) bool

Name filter files that do not have any name of the filter's arguments. For a route to pass the filter, it must end at least one of the names provided, for example:

Name(path, []string{"Img/Go"})

It will return true if `path` is one of:

  • /home/gopher/Img/Go
  • /Img/Go
  • Img/Go

But, will be false if it is one of:

  • MyImg/Go
  • Go
  • Img

This requires at least an argument.

func Pattern

func Pattern(path string, args []string) bool

Pattern filter files that do not match regular expression provided. This filter takes exactly one argument.

func Size

func Size(path string, args []string) bool

Size filter files that are smaller than the specified size.

func Type

func Type(path string, args []string) bool

Type filter files that are not the specified type.

Types

type Filter

type Filter func(path string, args []string) (passed bool)

Filter defines the specification of a filter, where path is the path to an existing file, and args are the filter arguments. And passed is a boolean that indicates if the file passed the filter.

func Negate added in v0.2.0

func Negate(filter Filter) Filter

Negate creates a new filter content the denied version of this.

Jump to

Keyboard shortcuts

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