|
3 months ago | |
---|---|---|
.gitignore | 1 year ago | |
LICENSE | 1 year ago | |
README.md | 3 months ago | |
go.mod | 6 months ago | |
wildcard.go | 1 year ago | |
wildcard_test.go | 6 months ago |
README.md
Go-wildcard
Go-wildcard is forked from Minio project
https://github.com/minio/minio/tree/master/pkg/wildcard
Why
This part of Minio project, a very cool, fast and light wildcard pattern matching.
Originally the purpose of this fork is to give access to this "lib" under Apache license, without importing the entire Minio project ...
Two function are available MatchSimple
and Match
MatchSimple
only covert*
usage (which is faster thanMatch
)Match
support full wildcard matching,*
and?
I know Regex, but they are much more complex, and slower (even prepared regex) ...
I know Glob, but most of the time, I only need simple wildcard matching.
This library remains under Apache License Version 2.0, but MinIO project is
migrated to GNU Affero General Public License 3.0 or later from
069432566f
How to
⚠️ WARNING: Unlike the GNU "libc", this library have no equivalent to "FNM_FILE_NAME". To do this you can use "path/filepath" https://pkg.go.dev/path/filepath#Glob
Using this fork
go get github.com/IGLOU-EU/go-wildcard@latest
Using Official Minio (GNU Affero General Public License 3.0 or later)
From
81d5688d56
the minio pkg are moved to https://github.com/minio/pkg
go get github.com/minio/pkg/wildcard@latest
Quick Example
This example shows a Go file with pattern matching ...
package main
import (
"fmt"
wildcard "github.com/IGLOU-EU/go-wildcard"
)
func main() {
str := "daaadabadmanda"
pattern := "da*da*da*"
result := wildcard.MatchSimple(pattern, str)
fmt.Println(str, pattern, result)
pattern = "?a*da*d?*"
result = wildcard.Match(pattern, str)
fmt.Println(str, pattern, result)
}