{"id":18894145,"url":"https://github.com/trailofbits/go-mutexasserts","last_synced_at":"2025-04-15T00:31:56.252Z","repository":{"id":57541263,"uuid":"265380874","full_name":"trailofbits/go-mutexasserts","owner":"trailofbits","description":"A small library that allows to check if Go mutexes are locked","archived":false,"fork":false,"pushed_at":"2025-02-12T18:17:30.000Z","size":14,"stargazers_count":23,"open_issues_count":0,"forks_count":2,"subscribers_count":27,"default_branch":"master","last_synced_at":"2025-03-28T12:51:14.661Z","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":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/trailofbits.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,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2020-05-19T22:17:49.000Z","updated_at":"2025-02-15T17:54:17.000Z","dependencies_parsed_at":"2024-06-18T18:51:52.174Z","dependency_job_id":null,"html_url":"https://github.com/trailofbits/go-mutexasserts","commit_stats":{"total_commits":4,"total_committers":2,"mean_commits":2.0,"dds":0.25,"last_synced_commit":"19999e7d3cef20712839127cac0163d1e06743ca"},"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/trailofbits%2Fgo-mutexasserts","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/trailofbits%2Fgo-mutexasserts/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/trailofbits%2Fgo-mutexasserts/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/trailofbits%2Fgo-mutexasserts/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/trailofbits","download_url":"https://codeload.github.com/trailofbits/go-mutexasserts/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248984395,"owners_count":21193742,"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":"2024-11-08T08:18:36.346Z","updated_at":"2025-04-15T00:31:55.734Z","avatar_url":"https://github.com/trailofbits.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# go-mutexasserts\n\nA small library that allows to check if Go mutexes are locked. It can be used to verify invariants/assumptions about [un]locking mutexes within certain functions.\n\nAlso, read the [\"How to check if a mutex is locked in Go\"](https://blog.trailofbits.com/2020/06/09/how-to-check-if-a-mutex-is-locked-in-go/)  blog post on that topic.\n\n## Installation\n\nUse `go get github.com/trailofbits/go-mutexasserts` to install this into your project and you can then import it with `github.com/trailofbits/go-mutexasserts` and use the `mutexasserts` package.\n\nThen, add assertions to your program and compile it with a `debug` tag (e.g., `go build -tags debug`) to enable mutex assertions.\n\n## API\n\n### Assertion functions\n\nThe `Assert*` functions print stack trace and exit program when they are called with an object that won't pass assertion.\nWe decided to use `exit(1)` instead of `panic()` because panics are sometimes (mis?)used for exception handling and we want to generate a fatal error.\n\n**The `mutexasserts.Assert*` functions will only check assertions if program is build with the `debug` tag (so e.g. `go build -tags debug`). Otherwise, those functions will be empty and optimized out by the compiler.**\n\n* `mutexasserts.AssertMutexLocked(m *sync.Mutex)`\n* `mutexasserts.AssertRWMutexLocked(m *sync.RWMutex)`\n* `mutexasserts.AssertRWMutexRLocked(m *sync.RWMutex)`\n\n### Getting mutex locked state functions\n\n* `mutexasserts.MutexLocked(m *sync.Mutex) bool`\n* `mutexasserts.RWMutexLocked(rw *sync.RWMutex) bool`\n* `mutexasserts.RWMutexRLocked(rw *sync.RWMutex) bool`\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftrailofbits%2Fgo-mutexasserts","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ftrailofbits%2Fgo-mutexasserts","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftrailofbits%2Fgo-mutexasserts/lists"}