{"id":21275686,"url":"https://github.com/halimath/glob","last_synced_at":"2025-03-15T13:13:44.492Z","repository":{"id":226336792,"uuid":"767758701","full_name":"halimath/glob","owner":"halimath","description":"Advanced file globs for golang","archived":false,"fork":false,"pushed_at":"2024-03-05T21:08:50.000Z","size":12,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-01-22T03:27:36.547Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/halimath.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}},"created_at":"2024-03-05T21:08:19.000Z","updated_at":"2024-03-18T16:09:49.000Z","dependencies_parsed_at":"2024-03-07T04:30:27.520Z","dependency_job_id":"59dd9313-5ef0-4dd1-bd4e-8768c7fe2d3e","html_url":"https://github.com/halimath/glob","commit_stats":null,"previous_names":["halimath/glob"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/halimath%2Fglob","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/halimath%2Fglob/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/halimath%2Fglob/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/halimath%2Fglob/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/halimath","download_url":"https://codeload.github.com/halimath/glob/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":243732303,"owners_count":20338839,"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":[],"created_at":"2024-11-21T09:36:09.918Z","updated_at":"2025-03-15T13:13:44.472Z","avatar_url":"https://github.com/halimath.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# glob\n\nAdvanced filesystem glob for golang\n\n![CI Status][ci-img-url] \n[![Go Report Card][go-report-card-img-url]][go-report-card-url] \n[![Package Doc][package-doc-img-url]][package-doc-url] \n[![Releases][release-img-url]][release-url]\n\n[ci-img-url]: https://github.com/halimath/glob/workflows/CI/badge.svg\n[go-report-card-img-url]: https://goreportcard.com/badge/github.com/halimath/glob\n[go-report-card-url]: https://goreportcard.com/report/github.com/halimath/glob\n[package-doc-img-url]: https://img.shields.io/badge/GoDoc-Reference-blue.svg\n[package-doc-url]: https://pkg.go.dev/github.com/halimath/glob\n[release-img-url]: https://img.shields.io/github/v/release/halimath/glob.svg\n[release-url]: https://github.com/halimath/glob/releases\n\n`glob` provides an advanced file system glob language, a superset of the \npattern language provided by that of the golang standard lib's `fs` package.\n\n# Installation\n\n`glob` is provided as a go module and requires go \u003e= 1.18.\n\n```shell\ngo get github.com/halimath/glob@main\n```\n\n# Usage\n\n`glob` provides a type `Pattern` which can be created using the `New` function:\n\n```go\npat, err := glob.New(\"**/*_test.go\")\n```\n\nA `Pattern` may then be used to search for matches in a `fs.FS`. If you want all\nmatches, simply use the `GlobFS` method:\n\n```go\nfiles, err := pat.GlobFS(fsys, \"\")\n```\n\n# Pattern language\n\nThe pattern language used by `glob` works similar to the \n[pattern format of `.gitignore`](https://git-scm.com/docs/gitignore). It is\ncompletely compatible with the pattern format used by `os.Glob` or `fs.Glob`\nand extends it.\n\nThe format is specified as the following EBNF:\n\n```ebnf\npattern = term, { '/', term };\n\nterm        = '**' | name;\nname        = { charSpecial | group | escapedChar | '*' | '?' };\ncharSpecial = (* any unicode rune except '/', '*', '?', '[' and '\\' *);\nchar        = (* any unicode rune *);\nescapedChar = '\\\\', char;\ngroup       = '[', [ '^' ] { escapedChar | groupChar | range } ']';\ngroupChar   = (* any unicode rune except '-' and ']' *);\nrange       = ( groupChar | escapedChar ), '-', (groupChar | escapedChar);\n```\n\nThe format operators have the following meaning:\n\n* any character (rune) matches the exactly this rune - with the following\n  exceptions\n* `/` works as a directory separator. It matches directory boundarys of the\n  underlying system independently of the separator char used by the OS.\n* `?` matches exactly one non-separator char\n* `*` matches any number of non-separator chars - including zero\n* `\\` escapes a character's special meaning allowing `*` and `?` to be used\n  as regular characters.\n* `**` matches any number of nested directories. If anything is matched it\n  always extends until a separator or the end of the name.\n* Groups can be defined using the `[` and `]` characters. Inside a group the\n  special meaning of the characters mentioned before is disabled but the\n  following rules apply\n    * any character used as part of the group acts as a choice to pick from\n    * if the group's first character is a `^` the whole group is negated\n    * a range can be defined using `-` matching any rune between low and high\n      inclusive\n    * Multiple ranges can be given. Ranges can be combined with choices.\n    * The meaning of `-` and `]` can be escacped using `\\`\n\n# Performance\n\n`glob` separates pattern parsing and matching. This can create a \nperformance benefit when applied repeatedly. When reusing a precompiled pattern\nto match filenames `glob` outperforms `filepath.Match` with both simple\nand complex patterns. When not reusing the parsed pattern, `filepath` works\nmuch faster (but lacks the additional features).\n\nTest | Execution time `[ns/op]` | Memory usage `[B/op]` | Allocations per op\n-- | --: | --: | --:\n`filepath` simple pattern                        |   15.5 | 0    | 0\n`glob` simple pattern (reuse)               |    3.9 | 0    | 0\n`glob` simple pattern (noreuse)             |  495.0 | 1112 | 5\n`filepath` complex pattern                       |  226.2 |    0 | 0\n`glob` complex pattern (reuse)              |  108.1 |    0 | 0\n`glob` complex pattern (noreuse)            | 1103.0 | 2280 | 8\n`glob` directory wildcard pattern (reuse)   |  111.7 |    0 | 0\n`glob` directory wildcard pattern (noreuse) | 1229.0 | 2280 | 8\n\n# License\n\nCopyright 2022 Alexander Metzner.\n\nLicensed under the Apache License, Version 2.0 (the \"License\");\nyou may not use this file except in compliance with the License.\nYou may obtain a copy of the License at\n\n[http://www.apache.org/licenses/LICENSE-2.0](http://www.apache.org/licenses/LICENSE-2.0)\n\nWITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\nSee the License for the specific language governing permissions and\nlimitations under the License.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhalimath%2Fglob","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fhalimath%2Fglob","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhalimath%2Fglob/lists"}