{"id":17537566,"url":"https://github.com/zenhack/go.notmuch","last_synced_at":"2025-10-06T14:35:19.530Z","repository":{"id":46367241,"uuid":"42639064","full_name":"zenhack/go.notmuch","owner":"zenhack","description":"Go language bindings for notmuch mail","archived":false,"fork":false,"pushed_at":"2022-09-18T17:35:08.000Z","size":117,"stargazers_count":20,"open_issues_count":1,"forks_count":8,"subscribers_count":10,"default_branch":"master","last_synced_at":"2025-04-23T21:08:22.599Z","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":"gpl-3.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/zenhack.png","metadata":{"files":{"readme":"README-INTERNALS.md","changelog":null,"contributing":null,"funding":null,"license":"COPYING","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2015-09-17T06:30:55.000Z","updated_at":"2024-04-29T03:28:35.000Z","dependencies_parsed_at":"2022-09-26T17:51:06.189Z","dependency_job_id":null,"html_url":"https://github.com/zenhack/go.notmuch","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/zenhack/go.notmuch","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zenhack%2Fgo.notmuch","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zenhack%2Fgo.notmuch/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zenhack%2Fgo.notmuch/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zenhack%2Fgo.notmuch/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/zenhack","download_url":"https://codeload.github.com/zenhack/go.notmuch/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zenhack%2Fgo.notmuch/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":278625365,"owners_count":26017926,"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-10-06T02:00:05.630Z","response_time":65,"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":[],"created_at":"2024-10-20T20:42:12.204Z","updated_at":"2025-10-06T14:35:19.480Z","avatar_url":"https://github.com/zenhack.png","language":"Go","readme":"This document describes some general patterns in the implementation.\n\n# Resource reclamation.\n\nThe library is written such that all resources will be released when the\ngarbage collector claims an object. However, we also export Close()\nmethods on each type that needs explicit cleanup. This is because the Go\ngarbage collector [isn't always able to make the right decisions about\nobjects with pointers to C memory][1].\n\n## Tracking dependencies\n\nEach notmuch object has a corresponding wrapper object:\nnotmuch_database_t is wrapped by DB, notmuch_query_t is wrapped by Query\nand so on. Each of these wrappers is an alias for the type cStruct,\nwhich holds a pointer to the underlying C object, and also to the\nwrappers for any objects referenced by the underlying C object (via the\n`parent` field).  This keeps the GC from collecting parent objects if\nthe children are still in use.\n\n## Creating objects\n\nWhen creating an object, the caller should set the `parent` field to a\npointer to the object's immediate parent object, and set cptr to the\nunderlying c pointer. Finally, calling setGcClose on the object will\ncause it to be released properly by the garbage collector.\n\n## Cleaning up\n\nCalling the `Close()` method on an object a second time is a no-op, and\nthus always safe. The primary reason for this is that it makes dealing\nwith mixing GC and manual reclamation simple.\n\nThe Close methods also clear all of their references to parent objects\nexplicitly. While this isn't strictly necessary, it means the GC\nwill know that they are unreachable sooner, if that becomes the case.\nPer the documentation for `runtime.SetFinalizer`, once the finalizer is\ncalled, the object will stick around until the next time the GC looks at\nit. Because of this, it won't otherwise even consider parent objects\nuntil the third pass at least.\n\nIn some cases, invoking the `*_destroy` function on an object also\ncleans up its children, in which case it becomes unsafe to then invoke\ntheir `*_destroy` function. cStruct handles all of the bookkeeping and\nsynchronization necessary to deal with this; derived types just need to\nmake proper use of doClose() in their Close() implementation (see the\ncomments in cstruct.go)\n\n[1]: https://gist.github.com/dwbuiten/c9865c4afb38f482702e#cleaning\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fzenhack%2Fgo.notmuch","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fzenhack%2Fgo.notmuch","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fzenhack%2Fgo.notmuch/lists"}