{"id":51043749,"url":"https://github.com/floatpane/jwz-go","last_synced_at":"2026-06-22T12:02:25.240Z","repository":{"id":361395566,"uuid":"1254283270","full_name":"floatpane/jwz-go","owner":"floatpane","description":"Jamie Zawinski's mail-threading algorithm for Go.","archived":false,"fork":false,"pushed_at":"2026-06-08T04:16:00.000Z","size":51,"stargazers_count":2,"open_issues_count":6,"forks_count":0,"subscribers_count":0,"default_branch":"master","last_synced_at":"2026-06-08T06:15:52.877Z","etag":null,"topics":["algorithm","conversations","email","email-client","email-parsing","go","golang","golang-library","jwz","jwz-algorithm","mail","mailing-list","message-id","mua","rfc5322","threading","threading-algorithm","tree-structure","zero-dependencies"],"latest_commit_sha":null,"homepage":"https://jwz.floatpane.com","language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/floatpane.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":"CONTRIBUTING.md","funding":".github/FUNDING.yml","license":"LICENSE","code_of_conduct":"CODE_OF_CONDUCT.md","threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":"SECURITY.md","support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null},"funding":{"github":"floatpane"}},"created_at":"2026-05-30T11:24:45.000Z","updated_at":"2026-06-04T19:18:32.000Z","dependencies_parsed_at":null,"dependency_job_id":null,"html_url":"https://github.com/floatpane/jwz-go","commit_stats":null,"previous_names":["floatpane/jwz-go"],"tags_count":1,"template":false,"template_full_name":null,"purl":"pkg:github/floatpane/jwz-go","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/floatpane%2Fjwz-go","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/floatpane%2Fjwz-go/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/floatpane%2Fjwz-go/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/floatpane%2Fjwz-go/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/floatpane","download_url":"https://codeload.github.com/floatpane/jwz-go/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/floatpane%2Fjwz-go/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":34647750,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-26T15:22:16.424Z","status":"online","status_checked_at":"2026-06-22T02:00:06.391Z","response_time":106,"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":["algorithm","conversations","email","email-client","email-parsing","go","golang","golang-library","jwz","jwz-algorithm","mail","mailing-list","message-id","mua","rfc5322","threading","threading-algorithm","tree-structure","zero-dependencies"],"created_at":"2026-06-22T12:02:24.180Z","updated_at":"2026-06-22T12:02:25.200Z","avatar_url":"https://github.com/floatpane.png","language":"Go","funding_links":["https://github.com/sponsors/floatpane"],"categories":[],"sub_categories":[],"readme":"\u003cdiv align=\"center\"\u003e\n\n# jwz-go\n\n**Jamie Zawinski's mail-threading algorithm for Go.**\n\n[![Go Version](https://img.shields.io/github/go-mod/go-version/floatpane/jwz-go)](https://golang.org)\n[![Go Reference](https://pkg.go.dev/badge/github.com/floatpane/jwz-go.svg)](https://pkg.go.dev/github.com/floatpane/jwz-go)\n[![GitHub release (latest by date)](https://img.shields.io/github/v/release/floatpane/jwz-go)](https://github.com/floatpane/jwz-go/releases)\n[![CI](https://github.com/floatpane/jwz-go/actions/workflows/ci.yml/badge.svg)](https://github.com/floatpane/jwz-go/actions/workflows/ci.yml)\n[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](LICENSE)\n\n\u003c/div\u003e\n\n`jwz-go` groups a flat list of email headers into conversation threads using\n[Jamie Zawinski's algorithm](https://www.jwz.org/doc/threading.html) — the same\nthreading model that ships in Mozilla Thunderbird and most modern MUAs.\nIt joins messages by `Message-ID` / `In-Reply-To` / `References`, and falls\nback to a locale-aware subject match (`Re:`, `Fwd:`, `AW:`, `SV:`, `RV:`,\n`Odp:`, …) when reference data is missing.\n\n## Features\n\n- **Pure Go, zero dependencies.** Drop-in for any mail client, archive viewer, or mailing-list tool.\n- **Deterministic output.** Threads sort newest-first by `LatestAt` with a stable EmailID tiebreaker.\n- **Locale-aware subject fallback.** Groups orphans across `Re:`, `Fwd:`, `AW:`, `SV:`, `RV:`, `Odp:`, `Antw:` and more.\n- **Loop-safe.** Cycle detection in `link()` prevents pathological reply chains from blowing the stack.\n- **Application-defined IDs.** Carry your own row/UID through the tree via `EmailID` — no extra lookup needed.\n\n## Install\n\n```bash\ngo get github.com/floatpane/jwz-go\n```\n\nRequires Go 1.26+.\n\n## Usage\n\n```go\npackage main\n\nimport (\n    \"fmt\"\n    \"time\"\n\n    \"github.com/floatpane/jwz-go\"\n)\n\nfunc main() {\n    base := time.Now()\n    threads := jwz.Build([]jwz.EmailHeader{\n        {ID: \"\u003ca@example\u003e\", Subject: \"Release plan\",       Date: base,                  EmailID: \"1\", Sender: \"alice\"},\n        {ID: \"\u003cb@example\u003e\", InReplyTo: \"\u003ca@example\u003e\",\n                            Subject: \"Re: Release plan\",   Date: base.Add(time.Minute), EmailID: \"2\", Sender: \"bob\"},\n        {ID: \"\u003cc@example\u003e\", References: []string{\"\u003ca@example\u003e\", \"\u003cb@example\u003e\"},\n                            Subject: \"Re: Re: Release plan\", Date: base.Add(2*time.Minute), EmailID: \"3\", Sender: \"carol\"},\n    })\n\n    for _, t := range threads {\n        fmt.Printf(\"%s (%d messages, last %s)\\n\", t.Subject, t.Count, t.LatestAt)\n    }\n}\n```\n\n### Types\n\n| Type | Description |\n|------|-------------|\n| `EmailHeader` | Input. Subset of RFC 5322 headers required for threading. |\n| `Thread` | Output. Conversation root + aggregate metadata. |\n| `ThreadNode` | One message inside a `Thread`, with children. |\n\n### Subject canonicalization\n\n`CanonicalSubject(s)` is exported for callers that want the same subject\nnormalization rules outside of threading — e.g. for search dedup or\nmailing-list digest collapse.\n\n```go\njwz.CanonicalSubject(\"Re: AW: SV: Release plan\") // -\u003e \"release plan\"\n```\n\n## How it works\n\n1. **Parse references.** Each header's `References` list is walked left→right; every consecutive pair is linked parent→child.\n2. **Resolve parent.** `In-Reply-To` wins; otherwise the last `References` entry.\n3. **Prune empty containers.** Tree is collapsed so that placeholder nodes with no real message disappear unless they have multiple children (which we keep, so siblings stay siblings).\n4. **Subject grouping.** Roots that share a canonical subject are merged under one tree — this catches forwarded threads and clients that drop References.\n5. **Sort.** Children by Date (stable); threads newest-first by `LatestAt`.\n\n## Documentation\n\nFull API reference: [pkg.go.dev/github.com/floatpane/jwz-go](https://pkg.go.dev/github.com/floatpane/jwz-go)\n\n## Contributing\n\nPRs welcome. See [CONTRIBUTING.md](CONTRIBUTING.md).\n\n## Security\n\nReport vulnerabilities privately via [SECURITY.md](SECURITY.md).\n\n## License\n\nMIT. See [LICENSE](LICENSE).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffloatpane%2Fjwz-go","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ffloatpane%2Fjwz-go","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffloatpane%2Fjwz-go/lists"}