{"id":13413884,"url":"https://github.com/qiniu/goc","last_synced_at":"2025-05-14T15:09:05.921Z","repository":{"id":38318894,"uuid":"261943284","full_name":"qiniu/goc","owner":"qiniu","description":"A Comprehensive Coverage Testing System for The Go Programming Language","archived":false,"fork":false,"pushed_at":"2024-11-15T10:16:06.000Z","size":9022,"stargazers_count":855,"open_issues_count":88,"forks_count":125,"subscribers_count":19,"default_branch":"master","last_synced_at":"2025-05-05T20:18:14.949Z","etag":null,"topics":["coverage-testing","go","testing-tools"],"latest_commit_sha":null,"homepage":"","language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/qiniu.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-07T03:46:25.000Z","updated_at":"2025-05-03T07:09:08.000Z","dependencies_parsed_at":"2023-01-27T17:00:38.453Z","dependency_job_id":"c8bbe7bc-0e16-48c7-8d11-5e656d9ae316","html_url":"https://github.com/qiniu/goc","commit_stats":{"total_commits":252,"total_committers":27,"mean_commits":9.333333333333334,"dds":0.6111111111111112,"last_synced_commit":"8ac46572fd0f9a19fa3a88db4ec56aad048eeb96"},"previous_names":[],"tags_count":25,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/qiniu%2Fgoc","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/qiniu%2Fgoc/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/qiniu%2Fgoc/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/qiniu%2Fgoc/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/qiniu","download_url":"https://codeload.github.com/qiniu/goc/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":252569641,"owners_count":21769517,"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-testing","go","testing-tools"],"created_at":"2024-07-30T20:01:51.926Z","updated_at":"2025-05-05T20:18:35.866Z","avatar_url":"https://github.com/qiniu.png","language":"Go","funding_links":[],"categories":["Testing","Tools","Go","测试","测试相关","Template Engines","Testing Frameworks","测试相关`测试库和测试数据集生成库`"],"sub_categories":["Testing Frameworks","Go","HTTP Clients","HTTP客户端","查询语"],"readme":"# goc\n[![Go Report Card](https://goreportcard.com/badge/github.com/qiniu/goc)](https://goreportcard.com/report/github.com/qiniu/goc)\n![](https://github.com/qiniu/goc/workflows/ut-check/badge.svg)\n![](https://github.com/qiniu/goc/workflows/style-check/badge.svg)\n![](https://github.com/qiniu/goc/workflows/e2e%20test/badge.svg)\n![Build Release](https://github.com/qiniu/goc/workflows/Build%20Release/badge.svg)\n[![codecov](https://codecov.io/gh/qiniu/goc/branch/master/graph/badge.svg)](https://codecov.io/gh/qiniu/goc)\n[![GoDoc](https://godoc.org/github.com/qiniu/goc?status.svg)](https://godoc.org/github.com/qiniu/goc)\n\n**English | [简体中文](./README_zh.md)**\n\ngoc is a comprehensive coverage testing system for The Go Programming Language, especially for some complex scenarios, like system testing code coverage collection and\naccurate testing.\n\nEnjoy, Have Fun!\n![Demo](docs/images/intro.gif)\n\n## Installation\n\n```\n# Mac/AMD64\ncurl -s https://api.github.com/repos/qiniu/goc/releases/latest | grep \"browser_download_url.*-darwin-amd64.tar.gz\" | cut -d : -f 2,3 | tr -d \\\" | xargs -n 1 curl -L | tar -zx \u0026\u0026 chmod +x goc \u0026\u0026 mv goc /usr/local/bin\n\n# Linux/AMD64\ncurl -s https://api.github.com/repos/qiniu/goc/releases/latest | grep \"browser_download_url.*-linux-amd64.tar.gz\" | cut -d : -f 2,3 | tr -d \\\" | xargs -n 1 curl -L | tar -zx \u0026\u0026 chmod +x goc \u0026\u0026 mv goc /usr/local/bin\n\n# Linux/386\ncurl -s https://api.github.com/repos/qiniu/goc/releases/latest | grep \"browser_download_url.*-linux-386.tar.gz\" | cut -d : -f 2,3 | tr -d \\\" | xargs -n 1 curl -L | tar -zx \u0026\u0026 chmod +x goc \u0026\u0026 mv goc /usr/local/bin\n\n```\n\nGoc supports both `GOPATH` project and `Go Modules` project with **Go 1.11+**. However, for developing goc, you need to install **Go 1.13+**.\n\n## Examples\nYou can use goc tool in many scenarios.\n\n### Code Coverage Collection for Your Golang System Tests\nGoc can collect code coverages at runtime for your long-run golang applications. To do that, normally just need three steps:\n\n1. use `goc server` to start a service registry center:\n    ```\n    ➜  simple-go-server git:(master) ✗ goc server\n    ```\n2. use `goc build` to build the target service, and run the generated binary. Here let's take the [simple-go-server](https://github.com/CarlJi/simple-go-server) project as example:\n    ```\n    ➜  simple-go-server git:(master) ✗ goc build .\n    ... // omit logs\n    ➜  simple-go-server git:(master) ✗ ./simple-go-server  \n    ```\n3. use `goc profile` to get the code coverage profile of the started simple server above:\n    ```\n    ➜  simple-go-server git:(master) ✗ goc profile\n    mode: atomic\n    enricofoltran/simple-go-server/main.go:30.13,48.33 13 1\n    enricofoltran/simple-go-server/main.go:48.33,50.3 1 0\n    enricofoltran/simple-go-server/main.go:52.2,65.12 5 1\n    enricofoltran/simple-go-server/main.go:65.12,74.46 7 1\n    enricofoltran/simple-go-server/main.go:74.46,76.4 1 0\n    ...   \n    ```\n    PS: \n    ```\n    enricofoltran/simple-go-server/main.go:30.13,48.33 13 1\n    \n    File: enricofoltran/simple-go-server/main.go\n    Position of first point of this code block: 30.13\n    Position of second point of this code block: 48.33\n    Number of statements of this code block: 13\n    Number of executions of this code block: 1\n    ```\n\n### Show Code Coverage Change at Runtime in Vscode\n\nWe provide a vscode extension - [Goc Coverage](https://marketplace.visualstudio.com/items?itemName=lyyyuna.goc) which can show highlighted covered source code at runtime. \n\n![Extension](docs/images/goc-vscode.gif)\n\n## Tips\n\n1. To understand the execution details of goc tool, you can use the `--debug` flag. Also we appreciate if you can provide such logs when submitting a bug to us.\n\n2. By default, the covered service will listen a random port in order to communicate with the goc server. This may not be suitable in [docker](https://docs.docker.com/engine/reference/commandline/run/#publish-or-expose-port--p---expose) or [kubernetes](https://kubernetes.io/docs/concepts/services-networking/service/#defining-a-service) environment since the port must be exposed explicitly in order to be accessible by others in such environment. For this kind of scenario, you can use `--agentport` flag to specify a fixed port when calling `goc build` or `goc install`.\n\n3. To use a remote goc server, you can use `--center` flag to compile the target service with `goc build` or `goc install` command.\n\n4. The coverage data is stored on each covered service side, so if one service needs to restart during test, this service's coverage data will be lost. For this case, you can use following steps to handle:\n\n    1. Before the service restarts, collect coverage with `goc profile -o a.cov`\n    2. After service restarted and test finished, collect coverage again with `goc profile -o b.cov`\n    3. Merge two coverage profiles together: `goc merge a.cov b.cov -o merge.cov`\n\n5. By default, goc will use the artifact's file name as its service name. You can overwrite it by setting environment variable `GOC_SERVICE_NAME`. (See [#293](https://github.com/qiniu/goc/issues/293) for details)\n\n## RoadMap\n- [x] Support code coverage collection for system testing.\n- [x] Support code coverage counters clear for the services under test at runtime.\n- [x] Support develop mode towards accurate testing.\n- [x] Support code coverage diff based on Pull Request.\n- [ ] Optimize the performance costed by code coverage counters.\n\n## Contributing\nWe welcome all kinds of contribution, including bug reports, feature requests, documentation improvements, UI refinements, etc.\n\nThanks to all [contributors](https://github.com/qiniu/goc/graphs/contributors)!!\n\n## License\nGoc is released under the Apache 2.0 license. See [LICENSE.txt](https://github.com/qiniu/goc/blob/master/LICENSE)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fqiniu%2Fgoc","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fqiniu%2Fgoc","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fqiniu%2Fgoc/lists"}