{"id":31830882,"url":"https://github.com/puigfp/invariant","last_synced_at":"2025-10-11T21:29:07.801Z","repository":{"id":57482994,"uuid":"192118301","full_name":"puigfp/invariant","owner":"puigfp","description":"Short helpers for checking invariants in your Go programs","archived":false,"fork":false,"pushed_at":"2019-08-14T18:18:37.000Z","size":4,"stargazers_count":2,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2024-06-20T10:07:53.025Z","etag":null,"topics":["panic"],"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/puigfp.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":"2019-06-15T19:50:10.000Z","updated_at":"2023-11-30T13:47:31.000Z","dependencies_parsed_at":"2022-08-27T20:02:45.452Z","dependency_job_id":null,"html_url":"https://github.com/puigfp/invariant","commit_stats":null,"previous_names":[],"tags_count":2,"template":false,"template_full_name":null,"purl":"pkg:github/puigfp/invariant","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/puigfp%2Finvariant","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/puigfp%2Finvariant/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/puigfp%2Finvariant/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/puigfp%2Finvariant/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/puigfp","download_url":"https://codeload.github.com/puigfp/invariant/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/puigfp%2Finvariant/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":279008860,"owners_count":26084517,"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-11T02:00:06.511Z","response_time":55,"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":["panic"],"created_at":"2025-10-11T21:29:06.599Z","updated_at":"2025-10-11T21:29:07.789Z","avatar_url":"https://github.com/puigfp.png","language":"Go","readme":"# invariant\n\nThis short package provides helpers for checking invariant in your Go programs.\n\nUsing this package, you can easily write debug assertions (ignored in \"release\" mode) and regular assertions, that will make your program panic if they are violated.\n\nPlease read the [GoDoc](https://godoc.org/github.com/puigfp/invariant) for more information.\n\n## Example\n\nI'm sure that your real world programs have more interesting invariants to check than this one.\n\n```go\n// Fibonnacci returns what you think it returns\n// n should be a positive integer.\nfunc Fibonacci(n int) int64 {\n    invariant.Assert(n \u003e= 0, \"n should be positive\")\n\n    var (\n        a int64 = 0\n        b int64 = 1\n    )\n\n    for n \u003e 0 {\n        a, b = b, a + b\n        n--\n    }\n\n    return a\n}\n```\n\n## References\n\nThis is inspired from an article by Matt Klein: [Crash early and crash often for more reliable software](https://medium.com/@mattklein123/crash-early-and-crash-often-for-more-reliable-software-597738dd21c5)\n\n\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpuigfp%2Finvariant","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fpuigfp%2Finvariant","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpuigfp%2Finvariant/lists"}