ProductPromotion
Logo

Go.Lang

made by https://0x3d.site

GitHub - IGLOU-EU/go-wildcard: ๐Ÿš€ Fast and light wildcard pattern matching.
๐Ÿš€ Fast and light wildcard pattern matching. Contribute to IGLOU-EU/go-wildcard development by creating an account on GitHub.
Visit Site

GitHub - IGLOU-EU/go-wildcard: ๐Ÿš€ Fast and light wildcard pattern matching.

GitHub - IGLOU-EU/go-wildcard: ๐Ÿš€ Fast and light wildcard pattern matching.

Go-wildcard

Go Report Card Go Reference BSD 3 Clause

๐Ÿ’ก Why

The purpose of this library is to provide a simple and fast wildcard pattern matching. Regex are much more complex and slower (even prepared regex)... and the filepath.Match is file-name-centric.

So, this library is a very fast and very simple alternative to regex and not tied to filename semantics unlike filepath.Match. There are no dependencies and is alocation free. ๐Ÿฅณ

๐Ÿงฐ Features

There are the supported patterns operators:

  • * match zero or more characters
  • ? match zero or one character
  • . match exactly one character

๐Ÿง 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#Match

There is super simple to use this library, you just have to import it and use the Match function.

package main

import (
	"fmt"

	"github.com/IGLOU-EU/go-wildcard/v2"
)

func main() {
    str := "daaadabadmanda"
    pattern := "?a*da*d.?*"

    result = wildcard.Match(pattern, str)
	fmt.Println(str, pattern, result)
}

๐Ÿ›ธ Benchmark

The benchmark is done with the following command:

go test -benchmem -run=^$ -bench .

The tested fonctions are:

  • regexp.MatchString(t.pattern, t.name)
  • filepath.Match(t.pattern, t.name)
  • oldMatchSimple(t.pattern, t.name) From the commit a899be92514ed08aa5271bc3b93320b719ce2114
  • oldMatch(t.pattern, t.name) From the commit a899be92514ed08aa5271bc3b93320b719ce2114
  • Match(t.pattern, t.name) The actual implementation
goos: linux
goarch: amd64
pkg: github.com/IGLOU-EU/go-wildcard/v2
cpu: AMD Ryzen 7 PRO 6850U with Radeon Graphics  

BenchmarkRegex/0-16              2062886           613.6 ns/op       767 B/op          9 allocs/op
BenchmarkRegex/1-16               240769          4891 ns/op        6592 B/op         26 allocs/op
BenchmarkRegex/2-16             11182353           106.1 ns/op       160 B/op          2 allocs/op
BenchmarkRegex/3-16               206820          5119 ns/op        6657 B/op         26 allocs/op
BenchmarkRegex/4-16               209696          5202 ns/op        7464 B/op         38 allocs/op
BenchmarkRegex/5-16             11510461           106.2 ns/op       160 B/op          2 allocs/op

BenchmarkFilepath/0-16          544894772            2.211 ns/op           0 B/op          0 allocs/op
BenchmarkFilepath/1-16           7447402           152.4 ns/op         0 B/op          0 allocs/op
BenchmarkFilepath/2-16          150307264            8.100 ns/op           0 B/op          0 allocs/op
BenchmarkFilepath/3-16           7204717           160.5 ns/op         0 B/op          0 allocs/op
BenchmarkFilepath/4-16          51796936            22.25 ns/op        0 B/op          0 allocs/op
BenchmarkFilepath/5-16           4137405           281.4 ns/op         0 B/op          0 allocs/op

BenchmarkOldMatchSimple/0-16    1000000000           0.5077 ns/op          0 B/op          0 allocs/op
BenchmarkOldMatchSimple/1-16    10006898           140.4 ns/op       176 B/op          1 allocs/op
BenchmarkOldMatchSimple/2-16    1000000000           0.7710 ns/op          0 B/op          0 allocs/op
BenchmarkOldMatchSimple/3-16     3102465           335.7 ns/op       352 B/op          2 allocs/op
BenchmarkOldMatchSimple/4-16     4941943           256.8 ns/op       336 B/op          2 allocs/op
BenchmarkOldMatchSimple/5-16     9047443           127.3 ns/op         0 B/op          0 allocs/op

BenchmarkOldMatch/0-16          1000000000           0.5054 ns/op          0 B/op          0 allocs/op
BenchmarkOldMatch/1-16           9655593           142.0 ns/op       176 B/op          1 allocs/op
BenchmarkOldMatch/2-16          1000000000           0.9732 ns/op          0 B/op          0 allocs/op
BenchmarkOldMatch/3-16           3008078           334.0 ns/op       352 B/op          2 allocs/op
BenchmarkOldMatch/4-16           4771064           251.4 ns/op       336 B/op          2 allocs/op
BenchmarkOldMatch/5-16           9545247           122.7 ns/op         0 B/op          0 allocs/op

BenchmarkMatch/0-16             1000000000           0.5314 ns/op          0 B/op          0 allocs/op
BenchmarkMatch/1-16             323842944            3.578 ns/op           0 B/op          0 allocs/op
BenchmarkMatch/2-16             924416408            1.201 ns/op           0 B/op          0 allocs/op
BenchmarkMatch/3-16             477003219            2.432 ns/op           0 B/op          0 allocs/op
BenchmarkMatch/4-16             125328649            9.016 ns/op           0 B/op          0 allocs/op
BenchmarkMatch/5-16             22776087            52.13 ns/op        0 B/op          0 allocs/op

PASS
ok      github.com/IGLOU-EU/go-wildcard/v2  39.328s

๐Ÿ•ฐ History

Originally, this library was a fork from the Minio project. The purpose was to give access to this "lib" under Apache license, without importing the entire Minio project. And to keep it usable under the Apache License Version 2.0 after MinIO project is migrated to GNU Affero General Public License 3.0 or later from update license change for MinIO

The actual Minio wildcard matching code can be found in wildcard.go

Articles
to learn more about the golang concepts.

Resources
which are currently available to browse on.

mail [email protected] to add your project or resources here ๐Ÿ”ฅ.

FAQ's
to know more about the topic.

mail [email protected] to add your project or resources here ๐Ÿ”ฅ.

Queries
or most google FAQ's about GoLang.

mail [email protected] to add more queries here ๐Ÿ”.

More Sites
to check out once you're finished browsing here.

0x3d
https://www.0x3d.site/
0x3d is designed for aggregating information.
NodeJS
https://nodejs.0x3d.site/
NodeJS Online Directory
Cross Platform
https://cross-platform.0x3d.site/
Cross Platform Online Directory
Open Source
https://open-source.0x3d.site/
Open Source Online Directory
Analytics
https://analytics.0x3d.site/
Analytics Online Directory
JavaScript
https://javascript.0x3d.site/
JavaScript Online Directory
GoLang
https://golang.0x3d.site/
GoLang Online Directory
Python
https://python.0x3d.site/
Python Online Directory
Swift
https://swift.0x3d.site/
Swift Online Directory
Rust
https://rust.0x3d.site/
Rust Online Directory
Scala
https://scala.0x3d.site/
Scala Online Directory
Ruby
https://ruby.0x3d.site/
Ruby Online Directory
Clojure
https://clojure.0x3d.site/
Clojure Online Directory
Elixir
https://elixir.0x3d.site/
Elixir Online Directory
Elm
https://elm.0x3d.site/
Elm Online Directory
Lua
https://lua.0x3d.site/
Lua Online Directory
C Programming
https://c-programming.0x3d.site/
C Programming Online Directory
C++ Programming
https://cpp-programming.0x3d.site/
C++ Programming Online Directory
R Programming
https://r-programming.0x3d.site/
R Programming Online Directory
Perl
https://perl.0x3d.site/
Perl Online Directory
Java
https://java.0x3d.site/
Java Online Directory
Kotlin
https://kotlin.0x3d.site/
Kotlin Online Directory
PHP
https://php.0x3d.site/
PHP Online Directory
React JS
https://react.0x3d.site/
React JS Online Directory
Angular
https://angular.0x3d.site/
Angular JS Online Directory