{"id":26183163,"url":"https://github.com/bitwizeshift/go-yamlpath","last_synced_at":"2026-05-09T07:32:35.376Z","repository":{"id":269850359,"uuid":"908646833","full_name":"bitwizeshift/go-yamlpath","owner":"bitwizeshift","description":null,"archived":false,"fork":false,"pushed_at":"2025-01-04T04:23:23.000Z","size":278,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-03-09T19:42:58.447Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"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/bitwizeshift.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE-APACHE","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":"2024-12-26T15:37:04.000Z","updated_at":"2025-01-04T04:23:26.000Z","dependencies_parsed_at":"2024-12-26T16:33:32.816Z","dependency_job_id":"1b5cd479-4a06-4158-8936-e25774b7a5e1","html_url":"https://github.com/bitwizeshift/go-yamlpath","commit_stats":null,"previous_names":["bitwizeshift/go-yamlpath"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bitwizeshift%2Fgo-yamlpath","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bitwizeshift%2Fgo-yamlpath/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bitwizeshift%2Fgo-yamlpath/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bitwizeshift%2Fgo-yamlpath/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/bitwizeshift","download_url":"https://codeload.github.com/bitwizeshift/go-yamlpath/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":243125676,"owners_count":20240276,"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":"2025-03-11T22:35:52.677Z","updated_at":"2025-12-25T07:58:13.225Z","avatar_url":"https://github.com/bitwizeshift.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# YAMLPath\n\n[![Build](https://github.com/bitwizeshift/go-yamlpath/actions/workflows/build-and-test.yaml/badge.svg)](https://github.com/bitwizeshift/go-yamlpath/actions/workflows/build-and-test.yaml)\n[![GoDoc](https://godoc.org/rodusek.dev/pkg/yamlpath?status.svg)](https://godoc.org/rodusek.dev/pkg/yamlpath)\n[![Go Report Card](https://goreportcard.com/badge/rodusek.dev/pkg/yamlpath)](https://goreportcard.com/report/rodusek.dev/pkg/yamlpath)\n\nA fluent and powerful YAML query language that can be embedded into any Go\nlibrary or application.\n\nThis language takes heavy inspiration from the [JSONPath] query language, but\nfeatures changes to the specification that simplify traversal and make the\nlanguage more fluent and readable.\n\nThis is built on top of the [`gopkg.in/yaml.v3`] library in Go by querying\n[`*yaml.Node`] objects directly. This allows for preserving source-location\ninformation -- which is powerful for providing diagnostics and error messages\nwhen validating YAML documents.\n\n[JSONPath]: https://goessner.net/articles/JsonPath/\n[`gopkg.in/yaml.v3`]: https://gopkg.in/yaml.v3\n\n## Quickstart\n\n* [📦 Installation](#installation)\n* [🧾 Features](#features)\n* [🚂 Example Use](#example-use)\n* [📚 Documentation](./docs/index.md)\n  * [📄 Grammar](./data/yamlpath.g4)\n  * [🔗 Extensions](./docs/extensions.md)\n  * [❓ FAQ](./docs/faq.md)\n* ⚖️ [MIT](./LICENSE-MIT) or [APACHE-2](./LICENSE-APACHE)\n\n## Installation\n\nTo install the package, use the following `go get` command:\n\n```sh\ngo get rodusek.dev/pkg/yamlpath\n```\n\n## Features\n\nThis library has full feature-parity with JSONPath, although not all features\nare provided in the same way. The follow features are supported:\n\n* ✅ Root and Current node selection with `$` and `@`[^1]\n* ✅ Child node selection with `.\u003cname\u003e`\n* ✅ Recursive descent with `descendants()` [^2]\n* ✅ Array index selection with `[\u003cnumber\u003e]`[^3]\n* ✅ Array slice selection with `[\u003cstart\u003e:\u003cend\u003e:\u003cstep\u003e]`\n* ✅ Union of multiple selections with `\u003cpath\u003e | \u003cpath\u003e`\n* ✅ Filtering with the `where` function, e.g. `$.people.where(name == \"bitwizeshift\")`\n* ✅ Comparison operators with `==`, `!=`, `\u003c`, `\u003e`, `\u003c=`, `\u003e=`\n* ✅ Containment operators with `in`, `nin`, `subsetof` (e.g. `age in [1, 2, 3]`)\n* ✅ Regular expression operator with `=~` (e.g. `name =~ /^b.*shift$/i`)\n* ✅ Logical expression operator with `\u0026\u0026`, `||`\n* ✅ Arithmetic operators with `+`, `-`, `*`, `/`, `%`\n* ✅ String concatenation with `key + \"string\"`\n* ✅ Function support (including custom user-defined functions!)\n* ✅ Dynamic subexpressions; any expression can be used as inputs to functions[^4]\n* ✅ External constants that can be provided at compile-time\n\n[^1]: These are optional in YAMLPath definitions. The path is always assumed to\n      be the \"current\" context path if unspecified; but can be provided for\n      disambiguation.\n[^2]: The `descendants()` function provides feature-parity with JSONPath's\n      recursive descent operator `..`. This is a more explicit way to select\n      descendants, and is more readable.\n[^3]: In YAMLPath, only indices are selected with the index operator. Fields are\n      selected with the `.` operator. To select fields with a string value, the\n      `select` function may be used (e.g. `$.select(\"some key\")`).\n[^4]: Dynamic subexpressions along with external constants provide rough\n      feature-parity with JSONPath's \"script\" functinality, since it enables the\n      calling language to provide data dynamically to YAMLPath expressions.\n\n## Example Use\n\n\u003e [!NOTE]\n\u003e For more examples, see the [examples](./_examples) directory.\n\nThis illustrates a simple example using this library to validate configurations,\nwith output diagnostics appearing in GitHub annotation format. This validates\nsome criteria on a `book` yaml object:\n\n```go\npath := yamlpath.MustCompile(\"store.book.where(price \u003c 10.00)\")\n\nfilepath := \"bookstore.yaml\"   // Some filepath to the YAML file\nfile, err := os.Open(filepath) // some file handle to the YAML file\nif err != nil {\n  log.Fatal(err)\n}\ndefer file.Close()\n\nvar node yaml.Node\nif err := yaml.NewDecoder(file).Decode(\u0026node); err != nil {\n  log.Fatal(err)\n}\n\nresult, err := path.Match(\u0026node)\nif err != nil {\n  log.Fatal(err)\n}\n\nfor _, node := range result {\n  if err := validateBook(result); err != nil {\n    // This is in GitHub annotation format\n    fmt.Println(\"::error file=%s,line=%d,title=Book validation failed::%v\",\n      filepath,\n      result.Line,\n      err,\n    )\n  }\n}\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbitwizeshift%2Fgo-yamlpath","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fbitwizeshift%2Fgo-yamlpath","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbitwizeshift%2Fgo-yamlpath/lists"}