{"id":37154600,"url":"https://github.com/lovoo/go-patricia","last_synced_at":"2026-01-14T18:17:16.013Z","repository":{"id":57513194,"uuid":"63240979","full_name":"lovoo/go-patricia","owner":"lovoo","description":"A generic patricia trie (also called radix tree) implemented in Go (Golang)","archived":false,"fork":true,"pushed_at":"2016-08-25T13:28:05.000Z","size":51,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-08-15T07:26:24.555Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"Go","has_issues":false,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":"tchap/go-patricia","license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/lovoo.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}},"created_at":"2016-07-13T11:37:06.000Z","updated_at":"2016-07-13T11:37:07.000Z","dependencies_parsed_at":null,"dependency_job_id":null,"html_url":"https://github.com/lovoo/go-patricia","commit_stats":null,"previous_names":[],"tags_count":8,"template":false,"template_full_name":null,"purl":"pkg:github/lovoo/go-patricia","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lovoo%2Fgo-patricia","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lovoo%2Fgo-patricia/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lovoo%2Fgo-patricia/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lovoo%2Fgo-patricia/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/lovoo","download_url":"https://codeload.github.com/lovoo/go-patricia/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lovoo%2Fgo-patricia/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28430246,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-01-14T16:38:47.836Z","status":"ssl_error","status_checked_at":"2026-01-14T16:34:59.695Z","response_time":107,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.5:443 state=error: 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":[],"created_at":"2026-01-14T18:17:15.299Z","updated_at":"2026-01-14T18:17:16.006Z","avatar_url":"https://github.com/lovoo.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# go-patricia #\n\n**Documentation**: [GoDoc](http://godoc.org/github.com/tchap/go-patricia/patricia)\u003cbr /\u003e\n**Build Status**: [![Build\nStatus](https://drone.io/github.com/tchap/go-patricia/status.png)](https://drone.io/github.com/tchap/go-patricia/latest)\u003cbr /\u003e\n**Test Coverage**: [![Coverage\nStatus](https://coveralls.io/repos/tchap/go-patricia/badge.png)](https://coveralls.io/r/tchap/go-patricia)\n\n\n---------------------\n\n## Fork Modification\n\n** This Fork modifies the tree behavior in a way that it will match extra data too.**\n\nSo after inserting *abc* into the tree, it will also match *abcdef*\n\n---------------------\n\n\n## About ##\n\nA generic patricia trie (also called radix tree) implemented in Go (Golang).\n\nThe patricia trie as implemented in this library enables fast visiting of items\nin some particular ways:\n\n1. visit all items saved in the tree,\n2. visit all items matching particular prefix (visit subtree), or\n3. given a string, visit all items matching some prefix of that string.\n\n`[]byte` type is used for keys, `interface{}` for values.\n\n`Trie` is not thread safe. Synchronize the access yourself.\n\n### State of the Project ###\n\nApparently some people are using this, so the API should not change often.\nAny ideas on how to make the library better are still welcome.\n\nMore (unit) testing would be cool as well...\n\n## Usage ##\n\nImport the package from GitHub first.\n\n```go\nimport \"github.com/tchap/go-patricia/patricia\"\n```\n\nYou can as well use gopkg.in thingie:\n\n```go\nimport \"gopkg.in/tchap/go-patricia.v2/patricia\"\n```\n\nThen you can start having fun.\n\n```go\nprintItem := func(prefix patricia.Prefix, item patricia.Item) error {\n\tfmt.Printf(\"%q: %v\\n\", prefix, item)\n\treturn nil\n}\n\n// Create a new default trie (using the default parameter values).\ntrie := NewTrie()\n\n// Create a new custom trie.\ntrie := NewTrie(MaxPrefixPerNode(16), MaxChildrenPerSparseNode(10))\n\n// Insert some items.\ntrie.Insert(Prefix(\"Pepa Novak\"), 1)\ntrie.Insert(Prefix(\"Pepa Sindelar\"), 2)\ntrie.Insert(Prefix(\"Karel Macha\"), 3)\ntrie.Insert(Prefix(\"Karel Hynek Macha\"), 4)\n\n// Just check if some things are present in the tree.\nkey := Prefix(\"Pepa Novak\")\nfmt.Printf(\"%q present? %v\\n\", key, trie.Match(key))\n// \"Pepa Novak\" present? true\nkey = Prefix(\"Karel\")\nfmt.Printf(\"Anybody called %q here? %v\\n\", key, trie.MatchSubtree(key))\n// Anybody called \"Karel\" here? true\n\n// Walk the tree in alphabetical order.\ntrie.Visit(printItem)\n// \"Karel Hynek Macha\": 4\n// \"Karel Macha\": 3\n// \"Pepa Novak\": 1\n// \"Pepa Sindelar\": 2\n\n// Walk a subtree.\ntrie.VisitSubtree(Prefix(\"Pepa\"), printItem)\n// \"Pepa Novak\": 1\n// \"Pepa Sindelar\": 2\n\n// Modify an item, then fetch it from the tree.\ntrie.Set(Prefix(\"Karel Hynek Macha\"), 10)\nkey = Prefix(\"Karel Hynek Macha\")\nfmt.Printf(\"%q: %v\\n\", key, trie.Get(key))\n// \"Karel Hynek Macha\": 10\n\n// Walk prefixes.\nprefix := Prefix(\"Karel Hynek Macha je kouzelnik\")\ntrie.VisitPrefixes(prefix, printItem)\n// \"Karel Hynek Macha\": 10\n\n// Delete some items.\ntrie.Delete(Prefix(\"Pepa Novak\"))\ntrie.Delete(Prefix(\"Karel Macha\"))\n\n// Walk again.\ntrie.Visit(printItem)\n// \"Karel Hynek Macha\": 10\n// \"Pepa Sindelar\": 2\n\n// Delete a subtree.\ntrie.DeleteSubtree(Prefix(\"Pepa\"))\n\n// Print what is left.\ntrie.Visit(printItem)\n// \"Karel Hynek Macha\": 10\n```\n\n## License ##\n\nMIT, check the `LICENSE` file.\n\n[![Gittip\nBadge](http://img.shields.io/gittip/alanhamlett.png)](https://www.gittip.com/tchap/\n\"Gittip Badge\")\n\n[![Bitdeli\nBadge](https://d2weczhvl823v0.cloudfront.net/tchap/go-patricia/trend.png)](https://bitdeli.com/free\n\"Bitdeli Badge\")\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flovoo%2Fgo-patricia","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Flovoo%2Fgo-patricia","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flovoo%2Fgo-patricia/lists"}