{"id":13723862,"url":"https://github.com/gobwas/glob","last_synced_at":"2025-05-14T02:02:49.351Z","repository":{"id":38554352,"uuid":"47125901","full_name":"gobwas/glob","owner":"gobwas","description":"Go glob","archived":false,"fork":false,"pushed_at":"2024-01-28T19:38:25.000Z","size":1359,"stargazers_count":985,"open_issues_count":34,"forks_count":68,"subscribers_count":25,"default_branch":"master","last_synced_at":"2025-05-06T02:02:49.965Z","etag":null,"topics":["glob","golang","pattern"],"latest_commit_sha":null,"homepage":null,"language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/gobwas.png","metadata":{"files":{"readme":"readme.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2015-11-30T14:57:38.000Z","updated_at":"2025-05-06T00:18:18.000Z","dependencies_parsed_at":"2024-06-18T11:26:58.715Z","dependency_job_id":null,"html_url":"https://github.com/gobwas/glob","commit_stats":{"total_commits":111,"total_committers":6,"mean_commits":18.5,"dds":0.3873873873873874,"last_synced_commit":"e7a84e9525fe90abcda167b604e483cc959ad4aa"},"previous_names":[],"tags_count":5,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gobwas%2Fglob","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gobwas%2Fglob/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gobwas%2Fglob/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gobwas%2Fglob/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/gobwas","download_url":"https://codeload.github.com/gobwas/glob/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":254052658,"owners_count":22006716,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["glob","golang","pattern"],"created_at":"2024-08-03T01:01:46.471Z","updated_at":"2025-05-14T02:02:49.330Z","avatar_url":"https://github.com/gobwas.png","language":"Go","funding_links":[],"categories":["Go"],"sub_categories":[],"readme":"# glob.[go](https://golang.org)\n\n[![GoDoc][godoc-image]][godoc-url] [![Build Status][travis-image]][travis-url]\n\n\u003e Go Globbing Library.\n\n## Install\n\n```shell\n    go get github.com/gobwas/glob\n```\n\n## Example\n\n```go\n\npackage main\n\nimport \"github.com/gobwas/glob\"\n\nfunc main() {\n    var g glob.Glob\n    \n    // create simple glob\n    g = glob.MustCompile(\"*.github.com\")\n    g.Match(\"api.github.com\") // true\n    \n    // quote meta characters and then create simple glob \n    g = glob.MustCompile(glob.QuoteMeta(\"*.github.com\"))\n    g.Match(\"*.github.com\") // true\n    \n    // create new glob with set of delimiters as [\".\"]\n    g = glob.MustCompile(\"api.*.com\", '.')\n    g.Match(\"api.github.com\") // true\n    g.Match(\"api.gi.hub.com\") // false\n    \n    // create new glob with set of delimiters as [\".\"]\n    // but now with super wildcard\n    g = glob.MustCompile(\"api.**.com\", '.')\n    g.Match(\"api.github.com\") // true\n    g.Match(\"api.gi.hub.com\") // true\n        \n    // create glob with single symbol wildcard\n    g = glob.MustCompile(\"?at\")\n    g.Match(\"cat\") // true\n    g.Match(\"fat\") // true\n    g.Match(\"at\") // false\n    \n    // create glob with single symbol wildcard and delimiters ['f']\n    g = glob.MustCompile(\"?at\", 'f')\n    g.Match(\"cat\") // true\n    g.Match(\"fat\") // false\n    g.Match(\"at\") // false \n    \n    // create glob with character-list matchers \n    g = glob.MustCompile(\"[abc]at\")\n    g.Match(\"cat\") // true\n    g.Match(\"bat\") // true\n    g.Match(\"fat\") // false\n    g.Match(\"at\") // false\n    \n    // create glob with character-list matchers \n    g = glob.MustCompile(\"[!abc]at\")\n    g.Match(\"cat\") // false\n    g.Match(\"bat\") // false\n    g.Match(\"fat\") // true\n    g.Match(\"at\") // false \n    \n    // create glob with character-range matchers \n    g = glob.MustCompile(\"[a-c]at\")\n    g.Match(\"cat\") // true\n    g.Match(\"bat\") // true\n    g.Match(\"fat\") // false\n    g.Match(\"at\") // false\n    \n    // create glob with character-range matchers \n    g = glob.MustCompile(\"[!a-c]at\")\n    g.Match(\"cat\") // false\n    g.Match(\"bat\") // false\n    g.Match(\"fat\") // true\n    g.Match(\"at\") // false \n    \n    // create glob with pattern-alternatives list \n    g = glob.MustCompile(\"{cat,bat,[fr]at}\")\n    g.Match(\"cat\") // true\n    g.Match(\"bat\") // true\n    g.Match(\"fat\") // true\n    g.Match(\"rat\") // true\n    g.Match(\"at\") // false \n    g.Match(\"zat\") // false \n}\n\n```\n\n## Performance\n\nThis library is created for compile-once patterns. This means, that compilation could take time, but \nstrings matching is done faster, than in case when always parsing template.\n\nIf you will not use compiled `glob.Glob` object, and do `g := glob.MustCompile(pattern); g.Match(...)` every time, then your code will be much more slower.\n\nRun `go test -bench=.` from source root to see the benchmarks:\n\nPattern | Fixture | Match | Speed (ns/op)\n--------|---------|-------|--------------\n`[a-z][!a-x]*cat*[h][!b]*eyes*` | `my cat has very bright eyes` | `true` | 432\n`[a-z][!a-x]*cat*[h][!b]*eyes*` | `my dog has very bright eyes` | `false` | 199\n`https://*.google.*` | `https://account.google.com` | `true` | 96\n`https://*.google.*` | `https://google.com` | `false` | 66\n`{https://*.google.*,*yandex.*,*yahoo.*,*mail.ru}` | `http://yahoo.com` | `true` | 163\n`{https://*.google.*,*yandex.*,*yahoo.*,*mail.ru}` | `http://google.com` | `false` | 197\n`{https://*gobwas.com,http://exclude.gobwas.com}` | `https://safe.gobwas.com` | `true` | 22\n`{https://*gobwas.com,http://exclude.gobwas.com}` | `http://safe.gobwas.com` | `false` | 24\n`abc*` | `abcdef` | `true` | 8.15\n`abc*` | `af` | `false` | 5.68\n`*def` | `abcdef` | `true` | 8.84\n`*def` | `af` | `false` | 5.74\n`ab*ef` | `abcdef` | `true` | 15.2\n`ab*ef` | `af` | `false` | 10.4\n\nThe same things with `regexp` package:\n\nPattern | Fixture | Match | Speed (ns/op)\n--------|---------|-------|--------------\n`^[a-z][^a-x].*cat.*[h][^b].*eyes.*$` | `my cat has very bright eyes` | `true` | 2553\n`^[a-z][^a-x].*cat.*[h][^b].*eyes.*$` | `my dog has very bright eyes` | `false` | 1383\n`^https:\\/\\/.*\\.google\\..*$` | `https://account.google.com` | `true` | 1205\n`^https:\\/\\/.*\\.google\\..*$` | `https://google.com` | `false` | 767\n`^(https:\\/\\/.*\\.google\\..*\\|.*yandex\\..*\\|.*yahoo\\..*\\|.*mail\\.ru)$` | `http://yahoo.com` | `true` | 1435\n`^(https:\\/\\/.*\\.google\\..*\\|.*yandex\\..*\\|.*yahoo\\..*\\|.*mail\\.ru)$` | `http://google.com` | `false` | 1674\n`^(https:\\/\\/.*gobwas\\.com\\|http://exclude.gobwas.com)$` | `https://safe.gobwas.com` | `true` | 1039\n`^(https:\\/\\/.*gobwas\\.com\\|http://exclude.gobwas.com)$` | `http://safe.gobwas.com` | `false` | 272\n`^abc.*$` | `abcdef` | `true` | 237\n`^abc.*$` | `af` | `false` | 100\n`^.*def$` | `abcdef` | `true` | 464\n`^.*def$` | `af` | `false` | 265\n`^ab.*ef$` | `abcdef` | `true` | 375\n`^ab.*ef$` | `af` | `false` | 145\n\n[godoc-image]: https://godoc.org/github.com/gobwas/glob?status.svg\n[godoc-url]: https://godoc.org/github.com/gobwas/glob\n[travis-image]: https://travis-ci.org/gobwas/glob.svg?branch=master\n[travis-url]: https://travis-ci.org/gobwas/glob\n\n## Syntax\n\nSyntax is inspired by [standard wildcards](http://tldp.org/LDP/GNU-Linux-Tools-Summary/html/x11655.htm),\nexcept that `**` is aka super-asterisk, that do not sensitive for separators.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgobwas%2Fglob","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fgobwas%2Fglob","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgobwas%2Fglob/lists"}