{"id":18832599,"url":"https://github.com/linka-cloud/protofilters","last_synced_at":"2026-02-26T07:42:14.441Z","repository":{"id":46237481,"uuid":"373833415","full_name":"linka-cloud/protofilters","owner":"linka-cloud","description":"Protobuf message filtering in Go","archived":false,"fork":false,"pushed_at":"2025-02-09T15:37:06.000Z","size":193,"stargazers_count":2,"open_issues_count":2,"forks_count":1,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-04-14T04:36:28.148Z","etag":null,"topics":["filter","filtering","go","golang","protobuf","reflection"],"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/linka-cloud.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,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2021-06-04T12:23:40.000Z","updated_at":"2025-02-09T15:37:09.000Z","dependencies_parsed_at":"2024-06-20T00:06:12.405Z","dependency_job_id":"4a81207e-8703-476c-a548-1f21872a4c22","html_url":"https://github.com/linka-cloud/protofilters","commit_stats":{"total_commits":31,"total_committers":1,"mean_commits":31.0,"dds":0.0,"last_synced_commit":"2f227744a1b59600a286e3ea94d411d5fc1db86e"},"previous_names":[],"tags_count":16,"template":false,"template_full_name":null,"purl":"pkg:github/linka-cloud/protofilters","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/linka-cloud%2Fprotofilters","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/linka-cloud%2Fprotofilters/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/linka-cloud%2Fprotofilters/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/linka-cloud%2Fprotofilters/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/linka-cloud","download_url":"https://codeload.github.com/linka-cloud/protofilters/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/linka-cloud%2Fprotofilters/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":267198676,"owners_count":24051559,"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","status":"online","status_checked_at":"2025-07-26T02:00:08.937Z","response_time":62,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"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":["filter","filtering","go","golang","protobuf","reflection"],"created_at":"2024-11-08T01:58:20.679Z","updated_at":"2026-02-26T07:42:09.414Z","avatar_url":"https://github.com/linka-cloud.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Proto Filters\n\n[![Go Reference](https://pkg.go.dev/badge/go.linka.cloud/protofilters.svg)](https://pkg.go.dev/go.linka.cloud/protofilters)\n\nProto filters provides a simple way to filter protobuf message based on field filter conditions.\n\n**Project status: *alpha***\n\nNot all planned features are completed.\nThe API, spec, status and other user facing objects are subject to change.\nWe do not support backward-compatibility for the alpha releases.\n\n\n## Overview\n\nThe main filter construct is the *Expression*:\n\n```protobuf\n// Expression represent a complete condition\n// fields are evaluated as the following expression:\n// condition \u0026\u0026 and_exprs || or_exprs\nmessage Expression {\n  FieldFilter condition = 1;\n  repeated Expression and_exprs = 2;\n  repeated Expression or_exprs = 3;\n}\n```\n\nThe two message filtering types available follow the same pattern as `google.protobuf.FieldMask`:\n\n```proto\nmessage FieldsFilter {\n  // filters is a map of \u003cfield path, Filter\u003e\n  map\u003cstring, Filter\u003e filters = 1;\n}\nmessage FieldFilter {\n    string field = 1;\n    Filter filter = 2;\n}\n```\n\nThe message's Field is selected by its path and compared against the provided typed filter:\n\n```proto\nmessage Filter {\n  oneof match {\n    StringFilter string = 1;\n    NumberFilter number = 2;\n    BoolFilter bool = 3;\n    NullFilter null = 4;\n    TimeFilter time = 5;\n    DurationFilter duration = 6;\n  }\n  // not negates the match result\n  bool not = 7;\n}\n```\n\nThe typed filters are the following:\n\n```proto\nmessage StringFilter {\n  message In {\n    repeated string values = 1;\n  }\n  oneof condition {\n    string equals = 1;\n    string regex = 2;\n    In in = 3;\n  }\n  bool case_insensitive = 4;\n}\n\nmessage NumberFilter {\n  message In {\n    repeated double values = 1;\n  }\n  oneof condition {\n    double equals = 1;\n    double sup = 2;\n    double inf = 3;\n    In in = 4;\n  }\n}\n\nmessage NullFilter {}\n\nmessage BoolFilter {\n  bool equals = 1;\n}\n\nmessage TimeFilter {\n  oneof condition {\n    google.protobuf.Timestamp equals = 1;\n    google.protobuf.Timestamp before = 2;\n    google.protobuf.Timestamp after = 3;\n  }\n}\n\nmessage DurationFilter {\n  oneof condition {\n    google.protobuf.Duration equals = 1;\n    google.protobuf.Duration sup = 2;\n    google.protobuf.Duration inf = 3;\n  }\n}\n```\n\n## Usage\n\nDownload:\n\n```bash\ngo get go.linka.cloud/protofilters\n```\n\nBasic example:\n\n```go\npackage main\n\nimport (\n\t\"log\"\n\n\t\"google.golang.org/protobuf/types/known/wrapperspb\"\n\n\t\"go.linka.cloud/protofilters\"\n\t\"go.linka.cloud/protofilters/filters\"\n\ttest \"go.linka.cloud/protofilters/tests/pb\"\n)\n\nfunc main() {\n\tm := \u0026test.Test{\n\t\tBoolField:      true,\n\t\tBoolValueField: wrapperspb.Bool(false),\n\t}\n\tok, err := protofilters.Match(m, filters.Where(\"bool_field\").True())\n\tif err != nil {\n\t\tlog.Fatalln(err)\n\t}\n\tif !ok {\n\t\tlog.Fatalln(\"should be true\")\n\t}\n\tok, err = protofilters.Match(m, filters.Where(\"bool_value_field\").False())\n\tif err != nil {\n\t\tlog.Fatalln(err)\n\t}\n\tif !ok {\n\t\tlog.Fatalln(\"should be true\")\n\t}\n}\n\n```\n\n## TODOs\n\n- [ ] support more languages\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flinka-cloud%2Fprotofilters","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Flinka-cloud%2Fprotofilters","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flinka-cloud%2Fprotofilters/lists"}