wildcard

package
v0.0.0-...-2ea17e8 Latest Latest
Warning

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

Go to latest
Published: May 4, 2019 License: GPL-3.0, GPL-3.0, GPL-3.0 Imports: 1 Imported by: 0

Documentation

Overview

Package wildcard implements a very simple wildcard matcher which supports only the term '*', which matches any sequence of characters. The match function, WildcardMatch, both parses the pattern and matches the target; there is no compile stage and WildcardMatch can be a drop in replacement anywhere a normal string comparison is done.

This package is very similar to and inspired by github.com/ryanuber/go- glob, but with performance optimizations; github.com/gobwas/glob offers a much richer glob syntax and faster performance for cases where a compiled glob state can be maintained.

Performance comparison:

wildcard:

BenchmarkFixedMatch-4 100000000 14.0 ns/op BenchmarkPrefixMatch-4 50000000 26.2 ns/op BenchmarkSuffixMatch-4 50000000 25.8 ns/op BenchmarkMultipleMatch-4 10000000 167 ns/op

github.com/ryanuber/go-glob:

BenchmarkFixedGoGlob-4 30000000 58.3 ns/op BenchmarkPrefixGoGlob-4 20000000 106 ns/op BenchmarkSuffixGoGlob-4 20000000 105 ns/op BenchmarkMultipleGoGlob-4 5000000 270 ns/op

github.com/gobwas/glob with precompile:

BenchmarkFixedGlobPrecompile-4 100000000 14.1 ns/op BenchmarkPrefixGlobPrecompile-4 200000000 6.66 ns/op BenchmarkSuffixGlobPrecompile-4 200000000 7.31 ns/op BenchmarkMultipleGlobPrecompile-4 10000000 151 ns/op

github.com/gobwas/glob with compile-and-match:

BenchmarkFixedGlob-4 300000 4120 ns/op BenchmarkPrefixGlob-4 1000000 1502 ns/op BenchmarkSuffixGlob-4 1000000 1501 ns/op BenchmarkMultipleGlob-4 300000 5203 ns/op

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Match

func Match(pattern, target string) bool

Types

This section is empty.

Jump to

Keyboard shortcuts

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