{"id":13598536,"url":"https://github.com/rillig/gobco","last_synced_at":"2025-07-31T13:38:34.714Z","repository":{"id":57499946,"uuid":"158654323","full_name":"rillig/gobco","owner":"rillig","description":"Measure branch coverage of golang tests","archived":false,"fork":false,"pushed_at":"2025-03-16T20:01:49.000Z","size":583,"stargazers_count":75,"open_issues_count":6,"forks_count":13,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-03-26T07:07:34.437Z","etag":null,"topics":["coverage","coverage-testing","go","golang"],"latest_commit_sha":null,"homepage":"","language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"bsd-2-clause","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/rillig.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":"2018-11-22T06:46:06.000Z","updated_at":"2025-03-16T20:01:28.000Z","dependencies_parsed_at":"2023-02-12T17:31:19.750Z","dependency_job_id":"80c79a39-2842-4d29-beb8-dc6fcba7be42","html_url":"https://github.com/rillig/gobco","commit_stats":null,"previous_names":[],"tags_count":20,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rillig%2Fgobco","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rillig%2Fgobco/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rillig%2Fgobco/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rillig%2Fgobco/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/rillig","download_url":"https://codeload.github.com/rillig/gobco/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248565523,"owners_count":21125509,"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":["coverage","coverage-testing","go","golang"],"created_at":"2024-08-01T17:00:53.471Z","updated_at":"2025-04-12T12:24:02.556Z","avatar_url":"https://github.com/rillig.png","language":"Go","funding_links":[],"categories":["Tools"],"sub_categories":["Go"],"readme":"[![Build Status](https://app.travis-ci.com/rillig/gobco.svg?branch=master)](https://app.travis-ci.com/github/rillig/gobco)\n[![codecov](https://codecov.io/gh/rillig/gobco/branch/master/graph/badge.svg)](https://codecov.io/gh/rillig/gobco)\n\n# GOBCO - Golang Branch Coverage\n\nGobco measures condition coverage of Go code.\n\nGobco is intended to be used in addition to `go test -cover`.\nFor example, gobco does not detect functions or methods that are completely\nunused, it only notices them if they contain any conditions or branches.\nGobco also doesn't cover `select` statements.\n\n## Installation\n\nWith go1.17 or later:\n\n```text\n$ go install github.com/rillig/gobco@latest\n```\n\nWith go1.16:\n\n```text\n$ go get github.com/rillig/gobco\n```\n\nOlder go releases are not supported.\n\n## Usage\n\nTo run gobco on a single package, run it in the package directory:\n\n~~~text\n$ gobco\n~~~\n\nThe output typically looks like the following example, taken from package\n[github.com/rillig/pkglint](https://github.com/rillig/pkglint):\n\n```text\nok  \tgithub.com/rillig/pkglint/v23\t29.648s\n\nCondition coverage: 8720/8840\n...\nchanges.go:171:61: condition \"n == 6\" was 12 times true but never false\ndistinfo.go:268:8: condition \"alg == \\\"SHA1\\\"\" was 16 times false but never true\ndistinfo.go:322:13: condition \"remainingHashes[0].algorithm == alg\" was 8 times true but never false\n...\nmkcondsimplifier.go:141:31: condition \"p[2] == p[1]-'A'+'a'\" was 26 times true but never false\n...\nvartypecheck.go:1027:11: condition \"len(invalid) \u003e 1\" was once false but never true\nvartypecheck.go:1628:42: condition \"cv.MkLines.pkg != nil\" was 8 times true but never false\nvartypecheck.go:1630:6: condition \"distname.IsConstant()\" was 8 times true but never false\n```\n\n## Adding custom test conditions\n\nIf you want to ensure that the tests cover a certain condition in your code,\nyou can insert the desired condition into the code\nand assign it to the underscore:\n\n~~~go\nfunc square(x int) int {\n    _ = x \u003e 50\n    _ = x == 0\n    _ = x \u003c 0\n\n    return x * x\n}\n~~~\n\nThe compiler will see that these conditions are side-effect-free and will thus\noptimize them away, so there is no runtime overhead.\n\nGobco only inserts its coverage code around expressions that are syntactically\nrecognizable as boolean expressions, such as comparisons, '\u0026\u0026', '||', '!'.\nWhen a boolean expression is merely passed around, there is no branch \ninvolved, thus nothing to do for branch coverage.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frillig%2Fgobco","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Frillig%2Fgobco","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frillig%2Fgobco/lists"}