You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
Adrien Kara 095902fa93
Fix typo ...
10 months ago
.gitignore Initial commit 10 months ago
LICENSE Initial commit 10 months ago
README.md Fix typo ... 10 months ago
go.mod Fix typo ... 10 months ago
wildcard.go Fork from minio pkg 10 months ago
wildcard_test.go Fix typo ... 10 months ago

README.md

Go-wildcard

Go Report Card Go Reference Go coverage Apache V2 License

Go-wildcard is forked from Minio project
https://github.com/minio/minio/tree/master/pkg/wildcard

Why

This part of Minio project is a very cool, fast and light wildcard pattern matching.
But using it, need to import the full Minio project inside your own ... And this is a cool, but BIG project.

Two function are available MatchSimple and Match

  • MatchSimple only covert * usage (he is a bit faster)
  • Match support full wildcard matching, * and ?

I know Regex, but this is a big part, and it is slow (even prepared regex) ...
I know Glob, but most of the time, I only need simple wildcard matching.

How to

For using GitHub repo

go mod edit -replace git.iglou.eu/Imported/go-wildcard=github.com/IGLOU-EU/go-wildcard@latest
go get git.iglou.eu/Imported/go-wildcard@latest

From selfhosted (I can't warranty the availability)

go get git.iglou.eu/Imported/go-wildcard@latest

Quick Example

This example shows a Go file which pattern matching ...
You can use the Github repos to github.com/IGLOU-EU/go-wildcard

package main

import (
	"fmt"
	"log"

	wildcard "git.iglou.eu/Imported/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)
}