{"id":38281767,"url":"https://github.com/matthewacon/gas","last_synced_at":"2026-01-17T02:00:11.704Z","repository":{"id":114261028,"uuid":"232167906","full_name":"Matthewacon/gas","owner":"Matthewacon","description":"Go runtime assertion library","archived":false,"fork":false,"pushed_at":"2020-01-16T19:20:58.000Z","size":10,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2024-06-21T03:01:35.387Z","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/Matthewacon.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-01-06T19:13:44.000Z","updated_at":"2020-01-16T19:21:00.000Z","dependencies_parsed_at":null,"dependency_job_id":"b46aa0f7-6553-449b-a8af-d003947ca481","html_url":"https://github.com/Matthewacon/gas","commit_stats":null,"previous_names":[],"tags_count":3,"template":false,"template_full_name":null,"purl":"pkg:github/Matthewacon/gas","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Matthewacon%2Fgas","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Matthewacon%2Fgas/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Matthewacon%2Fgas/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Matthewacon%2Fgas/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Matthewacon","download_url":"https://codeload.github.com/Matthewacon/gas/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Matthewacon%2Fgas/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28492047,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-01-17T00:50:05.742Z","status":"online","status_checked_at":"2026-01-17T02:00:07.808Z","response_time":85,"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":"2026-01-17T02:00:09.614Z","updated_at":"2026-01-17T02:00:11.651Z","avatar_url":"https://github.com/Matthewacon.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# gas\nA simple Go runtime assertion library.\n\n## Getting started\nAdd `github.com/Matthewacon/gas v0.0.3` to the require section in your `go.mod`.  \n\n### Prebuilt assertions\ngas provides a set of prebuilt assertion functions:\n```go\nAssertNonNil\nAssertPointer\nAssertStruct\nAssertInterface\nAssertSlice\nAssertArray\nAssertMap\nAssertFunc\n```\n\nAll prebuilt assertions conform to the function prototype specified by `gas.Assertion`:\n```go\ntype Assertion func(i interface{}, format ...interface{})\n```\nwhere `i` is the value that you want to test and `format...` are the formatting directive and subsequent\nformatting values, should you want to provide a message for an assertion failure.\n\n#### Example\n```go\npackage main\n\nimport \"github.com/Matthewacon/gas\"\n\nfunc main() {\n gas.AssertNonNil(nil, \"Uh oh, we didn't want that to be nil!\\n\")\n}\n```\n\n### Custom assertions\nAdditionally, gas provides two custom assertion functions for building custom type and kind assertions:\n```go\npackage main\n\nimport \"reflect\"\n\nfunc AssertType(k reflect.Kind, i interface{}, format ...interface{})\nfunc AssertKind(t reflect.Type, i interface{}, format ...interface{})\n```\n\n### Assertion clusters\nYou may have multiple assertions that you want to run, and you may want to handle a failure. Assertion \nclusters allow you to group all of your assertions into a handler and produce an error upon assertion\nfailure, rather than panic.\n\n```go\npackage main\n\nimport \"github.com/Matthewacon/gas\"\n\nfunc main() {\n err := gas.RunAssertionCluster(func() {\n  gas.AssertNonNil(3.14)\n  gas.AssertPointer(\u0026struct{}{})\n  gas.AssertFunc(\"am I a function?\", \"no I am not!\\n\")\n })\n if err != nil {\n  //handle failure\n }\n}\n```\n \n## Running the tests and benchmarks\nTest:\n```sh\ngo test ./...\n```\nBench:\n```sh\ngo test -bench=. ./...\n```\n\n## How expensive is it?\nAssertions are cached when built so reuse is cheap. See the benchmarks:\n```\nBenchmarkAssertNonNil-8                         \t545119610\t        2.20 ns/op\nBenchmarkAssertTypeConstant-8                   \t25229216\t       46.2 ns/op\nBenchmarkAssertTypeChange-8                     \t25249456\t       46.3 ns/op\nBenchmarkAssertKindConstant-8                   \t40084676\t       29.6 ns/op\nBenchmarkAssertKindChange-8                     \t28726497\t       41.9 ns/op\nBenchmarkAssertPointerNoPanicConstant-8         \t4603818\t      287 ns/op\nBenchmarkAssertPointerPanicConstant-8           \t1000000000\t        0.000003 ns/op\nBenchmarkAssertPointerNoPanicChange-8           \t3768321\t      292 ns/op\nBenchmarkAssertPointerPanicChange-8             \t1000000000\t        0.000006 ns/op\nBenchmarkAssertStructNoPanicConstant-8          \t5278958\t      247 ns/op\nBenchmarkAssertStructPanicConstant-8            \t1000000000\t        0.000006 ns/op\nBenchmarkAssertStructNoPanicChange-8            \t3755145\t      293 ns/op\nBenchmarkAssertStructPanicChange-8              \t1000000000\t        0.000006 ns/op\nBenchmarkAssertSliceNoPanicConstant-8           \t3755778\t      295 ns/op\nBenchmarkAssertSlicePanicConstant-8             \t1000000000\t        0.000005 ns/op\nBenchmarkAssertSliceNoPanicChange-8             \t3253950\t      391 ns/op\nBenchmarkAssertSlicePanicChange-8               \t1000000000\t        0.000007 ns/op\nBenchmarkAssertArrayNoPanicConstant-8           \t3740067\t      293 ns/op\nBenchmarkAssertArrayPanicConstant-8             \t1000000000\t        0.000006 ns/op\nBenchmarkAssertArrayNoPanicChange-8             \t5167531\t      248 ns/op\nBenchmarkAssertArrayPanicChange-8               \t1000000000\t        0.000006 ns/op\nBenchmarkAssertMapNoPanicConstant-8             \t3774405\t      286 ns/op\nBenchmarkAssertMapPanicConstant-8               \t1000000000\t        0.000004 ns/op\nBenchmarkAssertMapNoPanicChange-8               \t3108926\t      439 ns/op\nBenchmarkAssertMapPanicChange-8                 \t1000000000\t        0.000004 ns/op\nBenchmarkAssertFuncNoPanicConstant-8            \t3716983\t      294 ns/op\nBenchmarkAssertFuncPanicConstant-8              \t1000000000\t        0.000004 ns/op\nBenchmarkAssertFuncNoPanicChange-8              \t3411025\t      311 ns/op\nBenchmarkAssertFuncPanicChange-8                \t1000000000\t        0.000003 ns/op\nBenchmarkRunAssertionClusterNoErrorConstant-8   \t28611800\t       42.1 ns/op\nBenchmarkRunAssertionClusterErrorConstant-8     \t4980104\t      241 ns/op\nBenchmarkRunAssertionClusterNoErrorChange-8     \t29019114\t       41.3 ns/op\nBenchmarkRunAssertionClusterErrorChange-8       \t5455513\t      218 ns/op\n```\n\n## License\nThis project is licensed under the [M.I.T. License](https://github.com/Matthewacon/gas/blob/master/LICENSE).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmatthewacon%2Fgas","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmatthewacon%2Fgas","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmatthewacon%2Fgas/lists"}