implements glob pattern match. This is implemented according to IEEE Std 1003.1-2017.

glob

Go Reference

Package glob implements glob pattern match. This is implemented according to IEEE Std 1003.1-2017.

Special Chars

  • ?: A <question-mark> is a pattern that shall match any character.
  • *: An <asterisk> is a pattern that shall match multiple characters, as described in Patterns Matching Multiple Characters.
  • [: If an open bracket introduces a bracket expression as in RE Bracket Expression. See regexp/syntax.

Usage

Provides same interface with the standard library regexp.

package main

import (
	"fmt"

	"github.com/komem3/glob"
)

func main() {
	matcher := glob.MustCompile("Hello *d")
	fmt.Printf("%t", matcher.MatchString("Hello World"))
	// Output: true
}

Benchmark (glob vs regexp)

goos: linux
goarch: amd64
pkg: github.com/komem3/glob
cpu: 11th Gen Intel(R) Core(TM) i7-1165G7 @ 2.80GHz
BenchmarkGlob_Match/full_string[String]/glob-8    	 2097278	       525.1 ns/op	       0 B/op	       0 allocs/op
BenchmarkGlob_Match/full_string[String]/regex-8   	  121653	     14700 ns/op	       7 B/op	       0 allocs/op
BenchmarkGlob_Match/front_asterisk[String]/glob-8 	   17473	     67045 ns/op	       0 B/op	       0 allocs/op
BenchmarkGlob_Match/front_asterisk[String]/regex-8         	    1305	    839839 ns/op	     655 B/op	       0 allocs/op
BenchmarkGlob_Match/last_asterisk[String]/glob-8           	 7118701	       146.6 ns/op	       0 B/op	       0 allocs/op
BenchmarkGlob_Match/last_asterisk[String]/regex-8          	  390000	      3459 ns/op	       0 B/op	       0 allocs/op
BenchmarkGlob_Match/equal[String]/glob-8                   	16870214	        81.77 ns/op	       0 B/op	       0 allocs/op
BenchmarkGlob_Match/equal[String]/regex-8                  	11177442	       108.3 ns/op	       0 B/op	       0 allocs/op
BenchmarkGlob_Match/forward[String]/glob-8                 	 9613209	       145.3 ns/op	       0 B/op	       0 allocs/op
BenchmarkGlob_Match/forward[String]/regex-8                	 6637020	       182.5 ns/op	       0 B/op	       0 allocs/op
BenchmarkGlob_Match/backward[String]/glob-8                	  175374	      6596 ns/op	       0 B/op	       0 allocs/op
BenchmarkGlob_Match/backward[String]/regex-8               	  133812	      7701 ns/op	       0 B/op	       0 allocs/op
BenchmarkGlob_Match/partial(no_prefix)[String]/glob-8      	  744122	      1494 ns/op	       0 B/op	       0 allocs/op
BenchmarkGlob_Match/partial(no_prefix)[String]/regex-8     	    5305	    213007 ns/op	     161 B/op	       0 allocs/op
BenchmarkGlob_Match/partial(prefix)[String]/glob-8         	 3426975	       352.2 ns/op	       0 B/op	       0 allocs/op
BenchmarkGlob_Match/partial(prefix)[String]/regex-8        	    6175	    194106 ns/op	     138 B/op	       0 allocs/op
BenchmarkGlob_Match/one_pass[String]/glob-8                	11936358	        84.12 ns/op	       0 B/op	       0 allocs/op
BenchmarkGlob_Match/one_pass[String]/regex-8               	11558540	       115.0 ns/op	       0 B/op	       0 allocs/op
BenchmarkGlob_Match/full_string[Reader]/glob-8             	  424182	      2502 ns/op	      32 B/op	       1 allocs/op
BenchmarkGlob_Match/full_string[Reader]/regex-8            	   49975	     24444 ns/op	      32 B/op	       1 allocs/op
BenchmarkGlob_Match/front_asterisk[Reader]/glob-8          	   10000	    111649 ns/op	      32 B/op	       1 allocs/op
BenchmarkGlob_Match/front_asterisk[Reader]/regex-8         	    1032	   1043365 ns/op	      39 B/op	       1 allocs/op
BenchmarkGlob_Match/last_asterisk[Reader]/glob-8           	 5174074	       218.5 ns/op	      32 B/op	       1 allocs/op
BenchmarkGlob_Match/last_asterisk[Reader]/regex-8          	 3310730	       397.5 ns/op	      32 B/op	       1 allocs/op
BenchmarkGlob_Match/equal[Reader]/glob-8                   	 6150862	       183.4 ns/op	      32 B/op	       1 allocs/op
BenchmarkGlob_Match/equal[Reader]/regex-8                  	 5147601	       199.7 ns/op	      32 B/op	       1 allocs/op
BenchmarkGlob_Match/forward[Reader]/glob-8                 	 5149942	       216.2 ns/op	      32 B/op	       1 allocs/op
BenchmarkGlob_Match/forward[Reader]/regex-8                	 4580384	       253.4 ns/op	      32 B/op	       1 allocs/op
BenchmarkGlob_Match/backward[Reader]/glob-8                	   11835	    116044 ns/op	      32 B/op	       1 allocs/op
BenchmarkGlob_Match/backward[Reader]/regex-8               	    3776	    295302 ns/op	      33 B/op	       1 allocs/op
BenchmarkGlob_Match/partial(no_prefix)[Reader]/glob-8      	  325057	      3698 ns/op	      32 B/op	       1 allocs/op
BenchmarkGlob_Match/partial(no_prefix)[Reader]/regex-8     	   44877	     24113 ns/op	      32 B/op	       1 allocs/op
BenchmarkGlob_Match/partial(prefix)[Reader]/glob-8         	  428636	      3290 ns/op	      32 B/op	       1 allocs/op
BenchmarkGlob_Match/partial(prefix)[Reader]/regex-8        	   52003	     21867 ns/op	      32 B/op	       1 allocs/op
BenchmarkGlob_Match/one_pass[Reader]/glob-8                	 7638493	       156.8 ns/op	      32 B/op	       1 allocs/op
BenchmarkGlob_Match/one_pass[Reader]/regex-8               	 6075450	       182.6 ns/op	      32 B/op	       1 allocs/op

License

MIT

Owner
Similar Resources

A library that implements the outboxer pattern in go

Outboxer Outboxer is a go library that implements the outbox pattern. Getting Started Outboxer was designed to simplify the tough work of orchestratin

Dec 16, 2022

gobreaker implements the Circuit Breaker pattern in Go.

gobreaker gobreaker implements the Circuit Breaker pattern in Go.

Jan 7, 2023

Resequencer - A Go library that implements the resequencer pattern

resequencer A Go resequencer Introduction resequencer is a Go library that imple

Mar 19, 2022

My daily routine implements Atomic Pattern to the react app

RAGE (React Atomic Generator) Purpose My daily routine implements Atomic Pattern to the react app, I was doing that repeatedly, so the reason I create

Mar 8, 2022

This library implements the pub/sub pattern in a generic way. It uses Go's generic types to declare the type of the event.

observer This library implements the pub/sub pattern in a generic way. It uses Go's generic types to declare the type of the event. Usage go get githu

Nov 16, 2022

Extend go std library.

x-go go标准库的拓展,提供各种便利的工具 English Version concurrent 并发操作 lock 分布式锁与租约 result Rust 中的Result类型,在Go中的实现 types 基本类型的拓展和一些基本接口 xcodec 编解码接口与实现 xcontainer 集合

Jun 10, 2022

gopkg is a universal utility collection for Go, it complements offerings such as Boost, Better std, Cloud tools.

gopkg is a universal utility collection for Go, it complements offerings such as Boost, Better std, Cloud tools. Table of Contents Introduction

Jan 5, 2023

Multi-level logger based on go std log

mlog the mlog is multi-level logger based on go std log. It is: Simple Easy to use NOTHING ELSE package main import ( log "github.com/ccpaging/lo

May 18, 2022

Convenient Logger interface and std logger wrapper

Convenient logger interface and wrapper around std logger Interface type Logger interface { Error(err error) Debugf(format string, args ...interface

Nov 28, 2021

Script in Golang using Go 1.6 std lib methods to traverse directories and read the files

dev-check-in Script in Golang using Go 1.6 std lib methods to traverse directories and read the files Using only the standard library. It will find al

Dec 14, 2021

Logger - Simple logger without written with std pkg

Go-Logger Simple usage is: package main

Jan 2, 2022

Secret - Prevent your secrets from leaking into logs and std*

secret - Prevent your secrets from leaking into logs and std* The package provid

Dec 30, 2022

A Golang library to manipulate strings according to the word parsing rules of the UNIX Bourne shell.

shellwords A Golang library to manipulate strings according to the word parsing rules of the UNIX Bourne shell. Installation go get github.com/Wing924

Sep 27, 2022

A Go REST API allowing me to send messages to myself, on my phone, according to some events.

A Go REST API allowing me to send messages to myself, on my phone, according to some events.

go-telegram-notifier go-telegram-notifier A Go REST API wrapping the official Telegram API and used to send myself notifications, on my phone, based o

Apr 27, 2022

build and animate objects according to verlet physics. pure golang library

build and animate objects according to verlet physics. pure golang library

verlet build and animate objects according to verlet physics. pure golang library Examples depend on pixel library, see requirements to build them: wo

Dec 22, 2022

The golang tool of the zig compiler automatically compiles different targets according to the GOOS GOARCH environment variable. You need to install zig.

The golang tool of the zig compiler automatically compiles different targets according to the GOOS GOARCH environment variable. You need to install zig.

Nov 18, 2022

A http service to verify request and bounce them according to decisions made by CrowdSec.

traefik-crowdsec-bouncer A http service to verify request and bounce them according to decisions made by CrowdSec. Description This repository aim to

Dec 21, 2022

This api has been built according to the task assigned by Apponity.

This api has been built according to the task assigned by Apponity.

Appointy_Task This api has been built according to the task assigned by Apponity. All the tasks Provided have been completed Link to the Document of t

Oct 10, 2021

Golang examples of algorithms according to its time complexity.

big-o-notation-go Examples of algorithms and explanation for each Big O Notation category. Some examples are based in this video. If you didn't manage

Sep 1, 2022
Related tags
Takes an input http.FileSystem (likely at go generate time) and generates Go code that statically implements it.

vfsgen Package vfsgen takes an http.FileSystem (likely at go generate time) and generates Go code that statically implements the provided http.FileSys

Dec 18, 2022
Package cae implements PHP-like Compression and Archive Extensions.

Compression and Archive Extensions 中文文档 Package cae implements PHP-like Compression and Archive Extensions. But this package has some modifications de

Jun 16, 2022
Allows parsing CSV files into custom structs and implements required fields that can't be empty

Welcome to Go Custom CSV Parser ?? Allows parsing CSV files into custom structs and implements required fields that can't be empty ?? Homepage Install

Nov 9, 2021
searchHIBP is a golang tool that implements binary search over a hash ordered binary file.

searchHIBP is a golang tool that implements binary search over a hash ordered binary file.

Nov 9, 2021
Package ethernet implements marshaling and unmarshaling of IEEE 802.3 Ethernet II frames and IEEE 802.1Q VLAN tags. MIT Licensed.

ethernet Package ethernet implements marshaling and unmarshaling of IEEE 802.3 Ethernet II frames and IEEE 802.1Q VLAN tags. MIT Licensed. For more in

Dec 29, 2022
Powerful and versatile MIME sniffing package using pre-compiled glob patterns, magic number signatures, XML document namespaces, and tree magic for mounted volumes, generated from the XDG shared-mime-info database.

mimemagic Powerful and versatile MIME sniffing package using pre-compiled glob patterns, magic number signatures, xml document namespaces, and tree ma

Nov 3, 2022
Convert Gitignore to Glob patterns in Go

globify-gitignore Convert Gitignore to Glob patterns A Go

Nov 8, 2021
🔍 A jq-like tool that queries files via glob.

?? fq A jq-like tool that queries files via glob. ✅ Prerequisites Go 1.17+ jq (installed and on PATH) ?? Installation $ go get github.com/siketyan/fq

Dec 22, 2021
Go-ant-pattern: An ant pattern parser

go-ant-pattern - An ant pattern parser. Usage package main import ( "fmt" "github.com/cbuschka/go-ant-pattern" ) func main() { path := "

Dec 7, 2021
Leader-follower-pattern - Build leader-follower system pattern with etcd election

主备系统模式 原理 使用分布式锁实现主备节点系统。通过对分布式锁进行续期,保持长期锁, 从而使当前服务节点处于主服务节点 无法获取分布式锁的服务节点,则作为备选

Jan 24, 2022