• Stars
    star
    796
  • Rank 57,222 (Top 2 %)
  • Language
    Go
  • License
    Apache License 2.0
  • Created over 4 years ago
  • Updated 3 months ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

A Comprehensive Coverage Testing System for The Go Programming Language

goc

Go Report Card Build Release codecov GoDoc

English | 简体中文

goc is a comprehensive coverage testing system for The Go Programming Language, especially for some complex scenarios, like system testing code coverage collection and accurate testing.

Enjoy, Have Fun! Demo

Installation

# Mac/AMD64
curl -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 && chmod +x goc && mv goc /usr/local/bin

# Linux/AMD64
curl -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 && chmod +x goc && mv goc /usr/local/bin

# Linux/386
curl -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 && chmod +x goc && mv goc /usr/local/bin

Goc supports both GOPATH project and Go Modules project with Go 1.11+. However, for developing goc, you need to install Go 1.13+.

Examples

You can use goc tool in many scenarios.

Code Coverage Collection for Your Golang System Tests

Goc can collect code coverages at runtime for your long-run golang applications. To do that, normally just need three steps:

  1. use goc server to start a service registry center:
    ➜  simple-go-server git:(master) ✗ goc server
    
  2. use goc build to build the target service, and run the generated binary. Here let's take the simple-go-server project as example:
    ➜  simple-go-server git:(master) ✗ goc build .
    ... // omit logs
    ➜  simple-go-server git:(master) ✗ ./simple-go-server  
    
  3. use goc profile to get the code coverage profile of the started simple server above:
    ➜  simple-go-server git:(master) ✗ goc profile
    mode: atomic
    enricofoltran/simple-go-server/main.go:30.13,48.33 13 1
    enricofoltran/simple-go-server/main.go:48.33,50.3 1 0
    enricofoltran/simple-go-server/main.go:52.2,65.12 5 1
    enricofoltran/simple-go-server/main.go:65.12,74.46 7 1
    enricofoltran/simple-go-server/main.go:74.46,76.4 1 0
    ...   
    
    PS:
    enricofoltran/simple-go-server/main.go:30.13,48.33 13 1
    
    File: enricofoltran/simple-go-server/main.go
    Position of first point of this code block: 30.13
    Position of second point of this code block: 48.33
    Number of statements of this code block: 13
    Number of executions of this code block: 1
    

Show Code Coverage Change at Runtime in Vscode

We provide a vscode extension - Goc Coverage which can show highlighted covered source code at runtime.

Extension

Tips

  1. 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.

  2. 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 or kubernetes 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.

  3. To use a remote goc server, you can use --center flag to compile the target service with goc build or goc install command.

  4. 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:

    1. Before the service restarts, collect coverage with goc profile -o a.cov
    2. After service restarted and test finished, collect coverage again with goc profile -o b.cov
    3. Merge two coverage profiles together: goc merge a.cov b.cov -o merge.cov
  5. 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 for details)

RoadMap

  • Support code coverage collection for system testing.
  • Support code coverage counters clear for the services under test at runtime.
  • Support develop mode towards accurate testing.
  • Support code coverage diff based on Pull Request.
  • Optimize the performance costed by code coverage counters.

Contributing

We welcome all kinds of contribution, including bug reports, feature requests, documentation improvements, UI refinements, etc.

Thanks to all contributors!!

License

Goc is released under the Apache 2.0 license. See LICENSE.txt

More Repositories

1

js-sdk

Qiniu Cloud JavaScript SDK
JavaScript
1,378
star
2

logkit

Very powerful server agent for collecting & sending logs & metrics with an easy-to-use web console.
Go
1,350
star
3

qmgo

Qmgo - The Go driver for MongoDB. It‘s based on official mongo-go-driver but easier to use like Mgo.
Go
1,297
star
4

qshell

Shell Tools for Qiniu Cloud
Go
980
star
5

php-sdk

Qiniu Resource (Cloud) Storage SDK for PHP
PHP
810
star
6

httptest

Qiniu httptest utilities
Go
635
star
7

android-sdk

Qiniu Resource (Cloud) Storage SDK for Android
Java
626
star
8

nodejs-sdk

Qiniu Resource (Cloud) Storage SDK for Node.js
JavaScript
587
star
9

java-sdk

Qiniu Resource (Cloud) Storage SDK for Java
Java
549
star
10

python-sdk

Qiniu Resource (Cloud) Storage SDK for Python
Python
543
star
11

happy-dns-objc

dns library for objective c
Objective-C
491
star
12

iconv

Golang bindings to libiconv - Convert string to requested character encoding
Go
474
star
13

objc-sdk

Qiniu Resource (Cloud) Storage Objective-C SDK for Mac/iOS
Objective-C
436
star
14

arch

极客时间专栏《许式伟的架构课》相关的源代码:冯诺伊曼结构
Go
407
star
15

cerl

CERL2.0 - Erlang Model for C++
C++
376
star
16

gobook

The Go Programming Language
Go
362
star
17

py

Golang bindings to the CPython C-API
Go
319
star
18

qetag

qetag
Erlang
316
star
19

happy-dns-android

dns library for android
Java
293
star
20

QSunSync

七牛云文件同步图形化工具-Windows版本
C#
271
star
21

api.v7

Qiniu SDK for Golang (v7.x)
Go
264
star
22

csharp-sdk

Qiniu Resource (Cloud) Storage SDK for C#
C#
176
star
23

qpaint

极客时间专栏《许式伟的架构课》相关的源代码:QPaint (画图程序)
JavaScript
170
star
24

ruby-sdk

Qiniu Resource (Cloud) Storage SDK for Ruby
Ruby
164
star
25

kodo-browser

Kodo Browser 为七牛对象存储(Kodo)提供类似 Windows 资源管理器的功能。用户可以很方便的浏览文件,上传下载文件,支持断点续传等。
TypeScript
159
star
26

iOS-netdiag

Network Diagnosis for iOS
Objective-C
144
star
27

android-netdiag

Network Diagnosis for Android
Java
136
star
28

go-sdk

golang sdk
Go
136
star
29

webhook

Github.com webhook tools
Go
131
star
30

checkstyle

checkstyle for go
Go
128
star
31

legacy-ios-sdk

Qiniu Resource (Cloud) Storage SDK for iOS
Objective-C
103
star
32

QStreaming

A simplified, lightweight ETL pipeline framework for build stream/batch processing applications on top of Apache Spark
Scala
101
star
33

audio

Audio support for Go language.
Go
79
star
34

api.v6

Qiniu Resource (Cloud) Storage SDK for Golang (v6.x)
Go
68
star
35

c-sdk

Qiniu Resource (Cloud) Storage SDK for C/C++
C
63
star
36

x

Extension of Go standard library
Go
62
star
37

http

Extension module of golang http service
Go
61
star
38

qfetch

七牛资源批量抓取工具,根据指定URL列表抓取资源并存储到七牛云空间。
Go
59
star
39

qplayer-sdk

七牛播放器SDK支持点播,直播,首开快,延迟低,接口简单,易于使用。
Java
57
star
40

qiniutest

Qiniu httptest tool: qiniutest
Go
37
star
41

builder

TypeScript
34
star
42

text

Qiniu Text Processing Libraries for Go
Go
34
star
43

ip17mon-java

17mon ip库查询
Java
33
star
44

formstate-x

Manage state of form with ease.
TypeScript
33
star
45

developer.qiniu.com

developer center
JavaScript
32
star
46

mockhttp.v1

mockhttp is a unit test tool that allow you test web services without listening port
Go
29
star
47

form-upload

Form upload demo for Qiniu Cloud Storage
Python
28
star
48

happy-dns-java

dns query client for java
Java
27
star
49

qiniu-logging-plugin

轻松输出Java应用日志到七牛云大数据日志平台
Java
26
star
50

rust-sdk

Generic Qiniu Resource Storage SDK
Rust
26
star
51

dart-sdk

Qiniu Resource (Cloud) Storage SDK for Dart
Dart
23
star
52

sdkspec

Qiniu Resource (Cloud) Storage SDK Specification
23
star
53

pandora-go-sdk

Go
21
star
54

doxygen.io

http://doxygen.io/ - Doxygen as Service
Go
19
star
55

go_dep_search

golang dependency search tool
Go
19
star
56

typed-less-modules

🎁 Generate type definitions (.d.ts) for CSS Modules using LESS
TypeScript
18
star
57

QiniuLiveWX

七牛直播、播放、连麦最简微信小程序demo
JavaScript
17
star
58

mockhttp.v2

mockhttp is a unit test tool that allow you test web services without listening port
Go
16
star
59

qlive

七牛直播命令行工具
Go
15
star
60

objc-DownloadSDK

Qiniu DownloadSDK for iOS
Objective-C
14
star
61

dyn

Package for dynamic programming
Go
12
star
62

reviewbot

reviewbot - establish software engineering best practices and efficiently promote them within the organization.
Go
12
star
63

pandora-java-sdk

Pandora Java SDK 多种方式灵活接入Pandora 大数据平台
Java
11
star
64

goplus-dt

Data Technology base of the Go+ language
Go
9
star
65

pandora-docs-old

CSS
9
star
66

kirk

Go
9
star
67

c-sdk-for-windows

Qiniu Resource (Cloud) Storage Windows SDK for C/C++
C
8
star
68

qwebtesttool

七牛本地网络环境检测图形界面。
C#
8
star
69

pandora-docs

pandora 文档站
JavaScript
7
star
70

php5.3-sdk

七牛云存储 php5.3 sdk(已经过时,请使用 php-sdk)
PHP
7
star
71

version

Go
6
star
72

qfetch-m3u8

qfetch m3u8专用版本,可以把m3u8和其引用的ts文件直接抓取到七牛云存储空间中
Go
6
star
73

openacc

Open Account System
6
star
74

api

Qiniu Resource (Cloud) Storage SDK for Golang
6
star
75

pandora-js-sdk

浏览器端使用的Pandora 大数据客户端打点SDK
JavaScript
6
star
76

deprecated-js-sdk

Qiniu Resource Storage SDK for JavaScript(deprecated)
JavaScript
6
star
77

docs.qiniu.com

CSS
5
star
78

eslint-config

ESLint config for Qiniu
JavaScript
5
star
79

php5-sdk

七牛云存储 PHP SDK,兼容 PHP 5.3 以下版本(已经过时,请使用 php-sdk)
PHP
5
star
80

httpping

http ping for test service
Go
5
star
81

link-c-sdk

qnlinking
C
5
star
82

QNLiveKit_Android

qlive-sdk是七牛云推出的一款互动直播低代码解决方案sdk。只需几行代码快速接入互动连麦pk直播。
Kotlin
5
star
83

cpp-sdk

Qiniu Resource Storage C++ SDK
C
4
star
84

objc-netinfo

Get NetworkInfo
Objective-C
4
star
85

pandora-python-sdk

Python
4
star
86

apidoc

Qiniu Resource (Cloud) Storage API Documents
4
star
87

kubernetes-csi-driver

CSI Plugin for Kubernetes, Support Qiniu Cloud Storage.
Go
4
star
88

qiniulab

C#
3
star
89

stack-go

七牛云主机服务 Go SDK
Go
3
star
90

Android-Universal-Image-Loader-HappyDns

Android-Universal-Image-Loader and happy dns
Java
3
star
91

kodo-enterprise-image

Shell
3
star
92

pfop

七牛持久化数据处理请求服务工具
Go
3
star
93

pandora-python-sdk.v2

SDK for Pandora 2.0
Python
3
star
94

raven

TypeScript
3
star
95

api-specs

Qiniu API Specs by YAML
3
star
96

pandora-php-sdk

PHP
3
star
97

pandora-nodejs-sdk

JavaScript
3
star
98

wp-sdk

Windows Phone SDK for Qiniu Cloud Storage API[不再维护]
C#
3
star
99

pandora-c-sdk

C/C++ SDK for Pandora Platform
C
2
star
100

rust-download-sdk

七牛下载 Rust SDK,负责下载完整或部分七牛对象。该 SDK 主要服务于专有云场景,对于普通的公有云 / 私有云场景,建议使用 https://github.com/qiniu/rust-sdk
Rust
2
star