{"id":43209234,"url":"https://github.com/kuwa72/matcher","last_synced_at":"2026-02-01T07:14:03.823Z","repository":{"id":57623986,"uuid":"375631676","full_name":"kuwa72/matcher","owner":"kuwa72","description":"Simple query language of matching object and query for golang.","archived":false,"fork":false,"pushed_at":"2025-04-17T05:44:26.000Z","size":39,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-04-17T20:09:03.060Z","etag":null,"topics":["data-structures","filtering","golang","json","matcher","query","query-language","regex"],"latest_commit_sha":null,"homepage":"","language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/kuwa72.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2021-06-10T08:49:13.000Z","updated_at":"2025-04-17T06:11:42.000Z","dependencies_parsed_at":"2022-08-26T20:45:43.329Z","dependency_job_id":null,"html_url":"https://github.com/kuwa72/matcher","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"purl":"pkg:github/kuwa72/matcher","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kuwa72%2Fmatcher","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kuwa72%2Fmatcher/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kuwa72%2Fmatcher/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kuwa72%2Fmatcher/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/kuwa72","download_url":"https://codeload.github.com/kuwa72/matcher/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kuwa72%2Fmatcher/sbom","scorecard":{"id":574319,"data":{"date":"2025-08-11","repo":{"name":"github.com/kuwa72/matcher","commit":"f2de78ef752a60e1624bb94710cb857e5b834b03"},"scorecard":{"version":"v5.2.1-40-gf6ed084d","commit":"f6ed084d17c9236477efd66e5b258b9d4cc7b389"},"score":2.6,"checks":[{"name":"Dangerous-Workflow","score":-1,"reason":"no workflows found","details":null,"documentation":{"short":"Determines if the project's GitHub Action workflows avoid dangerous patterns.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#dangerous-workflow"}},{"name":"SAST","score":0,"reason":"no SAST tool detected","details":["Warn: no pull requests merged into dev branch"],"documentation":{"short":"Determines if the project uses static code analysis.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#sast"}},{"name":"Pinned-Dependencies","score":-1,"reason":"no dependencies found","details":null,"documentation":{"short":"Determines if the project has declared and pinned the dependencies of its build process.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#pinned-dependencies"}},{"name":"Maintained","score":0,"reason":"0 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 0","details":null,"documentation":{"short":"Determines if the project is \"actively maintained\".","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#maintained"}},{"name":"Token-Permissions","score":-1,"reason":"No tokens found","details":null,"documentation":{"short":"Determines if the project's workflows follow the principle of least privilege.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#token-permissions"}},{"name":"Packaging","score":-1,"reason":"packaging workflow not detected","details":["Warn: no GitHub/GitLab publishing workflow detected."],"documentation":{"short":"Determines if the project is published as a package that others can easily download, install, easily update, and uninstall.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#packaging"}},{"name":"Code-Review","score":0,"reason":"Found 0/17 approved changesets -- score normalized to 0","details":null,"documentation":{"short":"Determines if the project requires human code review before pull requests (aka merge requests) are merged.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#code-review"}},{"name":"Binary-Artifacts","score":10,"reason":"no binaries found in the repo","details":null,"documentation":{"short":"Determines if the project has generated executable (binary) artifacts in the source repository.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#binary-artifacts"}},{"name":"CII-Best-Practices","score":0,"reason":"no effort to earn an OpenSSF best practices badge detected","details":null,"documentation":{"short":"Determines if the project has an OpenSSF (formerly CII) Best Practices Badge.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#cii-best-practices"}},{"name":"Security-Policy","score":0,"reason":"security policy file not detected","details":["Warn: no security policy file detected","Warn: no security file to analyze","Warn: no security file to analyze","Warn: no security file to analyze"],"documentation":{"short":"Determines if the project has published a security policy.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#security-policy"}},{"name":"Fuzzing","score":0,"reason":"project is not fuzzed","details":["Warn: no fuzzer integrations found"],"documentation":{"short":"Determines if the project uses fuzzing.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#fuzzing"}},{"name":"License","score":0,"reason":"license file not detected","details":["Warn: project does not have a license file"],"documentation":{"short":"Determines if the project has defined a license.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#license"}},{"name":"Signed-Releases","score":-1,"reason":"no releases found","details":null,"documentation":{"short":"Determines if the project cryptographically signs release artifacts.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#signed-releases"}},{"name":"Branch-Protection","score":0,"reason":"branch protection not enabled on development/release branches","details":["Warn: branch protection not enabled for branch 'master'"],"documentation":{"short":"Determines if the default and release branches are protected with GitHub's branch protection settings.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#branch-protection"}},{"name":"Vulnerabilities","score":10,"reason":"0 existing vulnerabilities detected","details":null,"documentation":{"short":"Determines if the project has open, known unfixed vulnerabilities.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#vulnerabilities"}}]},"last_synced_at":"2025-08-20T17:14:35.496Z","repository_id":57623986,"created_at":"2025-08-20T17:14:35.496Z","updated_at":"2025-08-20T17:14:35.496Z"},"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28971759,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-02-01T06:46:42.625Z","status":"ssl_error","status_checked_at":"2026-02-01T06:44:56.173Z","response_time":56,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"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":["data-structures","filtering","golang","json","matcher","query","query-language","regex"],"created_at":"2026-02-01T07:14:03.126Z","updated_at":"2026-02-01T07:14:03.815Z","avatar_url":"https://github.com/kuwa72.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Matcher\n\n[![Go Version](https://img.shields.io/badge/Go-1.22%2B-blue.svg)](https://golang.org/)\n[![License](https://img.shields.io/badge/license-MIT-blue.svg)](LICENSE)\n\n\u003e **Powerful, flexible, and secure query language for filtering Go data structures**\n\nMatcher is a high-performance Go library that lets you filter data structures using a simple yet powerful query language. It supports complex expressions with regex patterns, logical operators, and parentheses grouping - perfect for filtering JSON data, in-memory collections, or implementing query capabilities in your APIs.\n\n*[日本語版はこちら](README-ja.md)*\n\n## ✨ Highlights\n\n- **Intuitive Query Language** - SQL-like syntax that's easy to learn and use\n- **Powerful Regex Support** - Match string patterns with full regex capabilities\n- **Parentheses Grouping** - Build complex nested expressions with precise control\n- **High Performance** - Optimized for speed with minimal allocations\n- **Security Built-in** - Protection against ReDoS attacks and resource exhaustion\n- **Context Support** - Cancel long-running operations with timeouts\n\n## 🚀 Quick Start\n\n### Installation\n\n```bash\ngo get github.com/kuwa72/matcher\n```\n\n### Basic Example\n\n```go\npackage main\n\nimport (\n\t\"fmt\"\n\t\"github.com/kuwa72/matcher\"\n)\n\nfunc main() {\n\t// Create a matcher with a query string\n\tm, err := matcher.NewMatcher(`name = \"John\" AND age \u003e 30`)\n\tif err != nil {\n\t\tpanic(err)\n\t}\n\n\t// Data to test against\n\tdata := matcher.Context{\n\t\t\"name\": \"John\",\n\t\t\"age\":  35,\n\t}\n\n\t// Test if the data matches the query\n\tresult, err := m.Test(\u0026data)\n\tif err != nil {\n\t\tpanic(err)\n\t}\n\n\tfmt.Printf(\"Match: %v\\n\", result) // Output: Match: true\n}\n```\n\n### CLI Tool\n\n```bash\n# Installation\ngo install github.com/kuwa72/matcher/matcher-cli@latest\n\n# Basic usage\necho '{\"name\":\"John\",\"age\":35}' | matcher-cli 'name = \"John\" AND age \u003e 30'\n\n# Debug output\necho '{\"name\":\"John\",\"age\":35}' | matcher-cli --debug 'name = \"John\" AND age \u003e 30'\n```\n\n## 🔍 Query Language\n\nMatcher uses an intuitive query language that's easy to learn yet powerful enough for complex filtering needs.\n\n### Key Features\n\n* **Logical Operators**: `AND`, `OR` (case-insensitive)\n* **Comparison Operators**: `=`, `!=`, `\u003c\u003e`, `\u003e`, `\u003e=`, `\u003c`, `\u003c=`\n* **Grouping**: Parentheses `()` for precise control over evaluation order\n* **Value Types**:\n  * **Numbers**: Integers and floating-point values\n  * **Strings**: Enclosed in single or double quotes\n  * **Regular Expressions**: Patterns enclosed in `/pattern/`\n  * **Booleans**: `TRUE` or `FALSE` (case-insensitive)\n  * **NULL**: Special value for null checks\n\n### Operator Precedence\n\n1. Comparisons (`=`, `!=`, etc.) are evaluated first\n2. `AND` conditions are evaluated next\n3. `OR` conditions are evaluated last\n\n### 📝 Example Queries\n\n```\n# Simple equality\nage = 30\n\n# Multiple conditions with AND\nname = \"John\" AND age \u003e 30 AND status = \"active\"\n\n# Using OR for alternatives\ncountry = \"USA\" OR country = \"Canada\"\n\n# Parentheses for grouping\n(status = \"pending\" OR status = \"approved\") AND created_at \u003e \"2025-01-01\"\n\n# Complex nested expressions\n(category = \"electronics\" AND (price \u003c 1000 OR rating \u003e 4.5)) OR featured = TRUE\n\n# Regular expression matching\nemail = /.*@gmail\\.com$/    # Match Gmail addresses\nname = /^(John|Jane).*/     # Names starting with John or Jane\n\n# Regex with forward slashes\npath = /\\/api\\/v1\\/.*/      # Match API v1 paths\nurl = /https:\\/\\/.*/       # Match HTTPS URLs\n\n# Combining everything\n(name = /J.*/ OR department = \"Engineering\") AND \n(age \u003e 30 AND salary \u003e= 70000) AND \n(status = \"Active\" OR status = \"Pending\")\n```\n\nSee the [test files](https://github.com/kuwa72/matcher/blob/main/parser_test.go) for more examples.\n\n## 🔒 Regular Expression Support\n\nMatcher provides powerful regex pattern matching for string values, with built-in security protections.\n\n### 🛡️ Security Features\n\nAll regex operations include protection against ReDoS attacks and resource exhaustion:\n\n- **Pattern Length Limit**: Maximum 1000 characters per pattern\n- **Complexity Limit**: No more than 20 repetition operators (`*`, `+`, `{...}`, `?`, `|`)\n- **Compilation Timeout**: 100ms timeout prevents catastrophic backtracking\n- **Asynchronous Processing**: Non-blocking compilation in separate goroutines\n\n### 📋 Syntax\n\n```\nfield = /pattern/   # Match if field matches the pattern\nfield != /pattern/  # Match if field does NOT match the pattern\n```\n\n### 📌 Important Notes\n\n- Uses Go's standard `regexp` package syntax\n- Works with equality (`=`) and inequality (`!=`, `\u003c\u003e`) operators\n- Applies only to string values\n- Escape forward slashes with backslash (`\\/`)\n\n### 🌟 Regex Examples\n\n```go\n// Email validation\nemail = /^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\\.[a-zA-Z]{2,}$/\n\n// URL path matching\npath = /\\/api\\/v[0-9]\\/users/\n\n// File extensions\nfilename = /\\.(jpg|png|gif)$/\n\n// Phone numbers\nphone = /^\\+?[0-9]{10,15}$/\n\n// Complex patterns with escaping\nurl = /https:\\/\\/[^\\/]+\\/[^\\/]+/\n```\n\n## ⚡ Performance\n\nMatcher is designed for high performance even with large datasets and complex queries.\n\n### 📊 Benchmark Results\n\nTested on 10,000 records (each with 20 fields) on an AMD Ryzen 9 5900HS:\n\n#### Complex Query Performance\n\n```\nBenchmarkComplexQueryWithLargeDataset-16    5    215ms/op    47MB/op    1,095,634 allocs/op\n```\n\n**Query tested:**\n```\n(name = /^J.*/ OR department = \"Engineering\") AND \n(age \u003e 30 AND salary \u003e= 70000) AND \n(status = \"Active\" OR status = \"Pending\") AND \npath = /\\/api\\/v[0-9]\\/.*/ AND score \u003e 50\n```\n\n#### Multiple Filters Performance\n\n```\nBenchmarkFilteringWithLargeDataset-16    1    1,325ms/op    282MB/op    6,580,071 allocs/op\n```\n\n### 🔧 Optimization Tips\n\n1. **Reuse Matchers** - Create once, reuse many times\n2. **Prefer Simple Comparisons** - Use `=`, `\u003e`, `\u003c` instead of regex when possible\n3. **Optimize Query Order** - Put likely-to-fail conditions first in AND expressions\n4. **Limit Regex Complexity** - Simpler patterns perform better\n\n## 🔧 Advanced Usage\n\n### Context Support\n\nMatcher supports Go's context package for timeout and cancellation:\n\n```go\n// Create a context with timeout\nctx, cancel := context.WithTimeout(context.Background(), 5*time.Second)\ndefer cancel()\n\n// Test with context\nresult, err := matcher.TestWithContext(ctx, \u0026data)\n```\n\n### JSON Integration\n\nMatcher works seamlessly with JSON data:\n\n```go\n// Parse JSON data\nvar data matcher.Context\njson.Unmarshal([]byte(`{\"name\":\"John\",\"age\":35}`), \u0026data)\n\n// Create matcher\nmatcher, _ := matcher.NewMatcher(`name = \"John\" AND age \u003e 30`)\n\n// Test against JSON data\nresult, _ := matcher.Test(\u0026data)\n```\n\n## 📦 Requirements\n\n- Go 1.22 or higher\n\n## 📄 License\n\nThis project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details.\n\n## 👥 Contributing\n\nContributions are welcome! Feel free to open issues or submit pull requests.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkuwa72%2Fmatcher","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fkuwa72%2Fmatcher","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkuwa72%2Fmatcher/lists"}