Repository: qiniu/goc
Pull request #191 (2021-05-26 14:57:04)

feat: support singleton mode
support run singleton. Not always need a goc server

```
 goc build -o main --debug . --singleton --agentport=:7866
```




qiniu-bot: [APPROVALNOTIFIER] This PR is **NOT APPROVED**

This pull-request has been approved by: *<a href="https://github.com/qiniu/goc/pull/191#" title="Author self-approved">rrylee</a>*
To complete the [pull request process](https://git.k8s.io/community/contributors/guide/owners.md#the-code-review-process), please assign **e06084**
You can assign the PR to them by writing `/assign @e06084` in a comment when ready.

The full list of commands accepted by this bot can be found [here](https://go.k8s.io/bot-commands?repo=qiniu%2Fgoc).

<details open>
Needs approval from an approver in each of these files:

- **[OWNERS](https://github.com/qiniu/goc/blob/master/OWNERS)**

Approvers can indicate their approval by writing `/approve` in a comment
Approvers can cancel approval by writing `/approve cancel` in a comment
</details>
<!-- META={"approvers":["e06084"]} -->
codecov[bot]: # [Codecov](https://codecov.io/gh/qiniu/goc/pull/191?src=pr&el=h1&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=qiniu) Report
> Merging [#191](https://codecov.io/gh/qiniu/goc/pull/191?src=pr&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=qiniu) (5cc60e4) into [master](https://codecov.io/gh/qiniu/goc/commit/63c7438a635d4e707e823655fe9043cfcdeb7c2f?el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=qiniu) (63c7438) will **decrease** coverage by `0.10%`.
> The diff coverage is `71.42%`.

[![Impacted file tree graph](https://codecov.io/gh/qiniu/goc/pull/191/graphs/tree.svg?width=650&height=150&src=pr&token=7AHPDDLXQ3&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=qiniu)](https://codecov.io/gh/qiniu/goc/pull/191?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=qiniu)

```diff
@@            Coverage Diff             @@
##           master     #191      +/-   ##
==========================================
- Coverage   68.00%   67.90%   -0.11%     
==========================================
  Files          34       34              
  Lines        1738     1745       +7     
==========================================
+ Hits         1182     1185       +3     
- Misses        451      454       +3     
- Partials      105      106       +1     
```

| Flag | Coverage Δ | |
|---|---|---|
| e2e-1.11.x | `?` | |
| e2e-1.12.x | `?` | |
| e2e-1.13.x | `?` | |
| e2e-1.14.x | `?` | |
| e2e-1.15.x | `?` | |
| e2e-1.16.x | `?` | |
| unittest-1.13.x | `67.90% <71.42%> (+0.12%)` | :arrow_up: |
| unittest-1.14.x | `?` | |
| unittest-1.15.x | `?` | |
| unittest-1.16.x | `?` | |

Flags with carried forward coverage won't be shown. [Click here](https://docs.codecov.io/docs/carryforward-flags?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=qiniu#carryforward-flags-in-the-pull-request-comment) to find out more.

| [Impacted Files](https://codecov.io/gh/qiniu/goc/pull/191?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=qiniu) | Coverage Δ | |
|---|---|---|
| [cmd/cover.go](https://codecov.io/gh/qiniu/goc/pull/191/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=qiniu#diff-Y21kL2NvdmVyLmdv) | `18.75% <0.00%> (-1.25%)` | :arrow_down: |
| [cmd/run.go](https://codecov.io/gh/qiniu/goc/pull/191/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=qiniu#diff-Y21kL3J1bi5nbw==) | `4.87% <0.00%> (-0.13%)` | :arrow_down: |
| [pkg/cover/instrument.go](https://codecov.io/gh/qiniu/goc/pull/191/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=qiniu#diff-cGtnL2NvdmVyL2luc3RydW1lbnQuZ28=) | `19.04% <ø> (ø)` | |
| [cmd/build.go](https://codecov.io/gh/qiniu/goc/pull/191/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=qiniu#diff-Y21kL2J1aWxkLmdv) | `63.33% <100.00%> (+1.26%)` | :arrow_up: |
| [cmd/commonflags.go](https://codecov.io/gh/qiniu/goc/pull/191/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=qiniu#diff-Y21kL2NvbW1vbmZsYWdzLmdv) | `93.93% <100.00%> (+0.18%)` | :arrow_up: |
| [cmd/install.go](https://codecov.io/gh/qiniu/goc/pull/191/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=qiniu#diff-Y21kL2luc3RhbGwuZ28=) | `62.06% <100.00%> (+1.35%)` | :arrow_up: |
| [pkg/cover/cover.go](https://codecov.io/gh/qiniu/goc/pull/191/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=qiniu#diff-cGtnL2NvdmVyL2NvdmVyLmdv) | `69.62% <100.00%> (+0.28%)` | :arrow_up: |
| [pkg/build/legacy.go](https://codecov.io/gh/qiniu/goc/pull/191/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=qiniu#diff-cGtnL2J1aWxkL2xlZ2FjeS5nbw==) | `94.11% <0.00%> (-5.89%)` | :arrow_down: |

codecov[bot]: # [Codecov](https://codecov.io/gh/qiniu/goc/pull/191?src=pr&el=h1&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=qiniu) Report
> Merging [#191](https://codecov.io/gh/qiniu/goc/pull/191?src=pr&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=qiniu) (5cc60e4) into [master](https://codecov.io/gh/qiniu/goc/commit/63c7438a635d4e707e823655fe9043cfcdeb7c2f?el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=qiniu) (63c7438) will **decrease** coverage by `0.10%`.
> The diff coverage is `71.42%`.

[![Impacted file tree graph](https://codecov.io/gh/qiniu/goc/pull/191/graphs/tree.svg?width=650&height=150&src=pr&token=7AHPDDLXQ3&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=qiniu)](https://codecov.io/gh/qiniu/goc/pull/191?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=qiniu)

```diff
@@            Coverage Diff             @@
##           master     #191      +/-   ##
==========================================
- Coverage   68.00%   67.90%   -0.11%     
==========================================
  Files          34       34              
  Lines        1738     1745       +7     
==========================================
+ Hits         1182     1185       +3     
- Misses        451      454       +3     
- Partials      105      106       +1     
```

| Flag | Coverage Δ | |
|---|---|---|
| e2e-1.11.x | `?` | |
| e2e-1.12.x | `?` | |
| e2e-1.13.x | `?` | |
| e2e-1.14.x | `?` | |
| e2e-1.15.x | `?` | |
| e2e-1.16.x | `?` | |
| unittest-1.13.x | `67.90% <71.42%> (+0.12%)` | :arrow_up: |
| unittest-1.14.x | `67.79% <71.42%> (+0.01%)` | :arrow_up: |
| unittest-1.15.x | `67.79% <71.42%> (-0.22%)` | :arrow_down: |
| unittest-1.16.x | `67.79% <71.42%> (+0.01%)` | :arrow_up: |

Flags with carried forward coverage won't be shown. [Click here](https://docs.codecov.io/docs/carryforward-flags?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=qiniu#carryforward-flags-in-the-pull-request-comment) to find out more.

| [Impacted Files](https://codecov.io/gh/qiniu/goc/pull/191?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=qiniu) | Coverage Δ | |
|---|---|---|
| [cmd/cover.go](https://codecov.io/gh/qiniu/goc/pull/191/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=qiniu#diff-Y21kL2NvdmVyLmdv) | `18.75% <0.00%> (-1.25%)` | :arrow_down: |
| [cmd/run.go](https://codecov.io/gh/qiniu/goc/pull/191/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=qiniu#diff-Y21kL3J1bi5nbw==) | `4.87% <0.00%> (-0.13%)` | :arrow_down: |
| [pkg/cover/instrument.go](https://codecov.io/gh/qiniu/goc/pull/191/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=qiniu#diff-cGtnL2NvdmVyL2luc3RydW1lbnQuZ28=) | `19.04% <ø> (ø)` | |
| [cmd/build.go](https://codecov.io/gh/qiniu/goc/pull/191/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=qiniu#diff-Y21kL2J1aWxkLmdv) | `63.33% <100.00%> (+1.26%)` | :arrow_up: |
| [cmd/commonflags.go](https://codecov.io/gh/qiniu/goc/pull/191/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=qiniu#diff-Y21kL2NvbW1vbmZsYWdzLmdv) | `93.93% <100.00%> (+0.18%)` | :arrow_up: |
| [cmd/install.go](https://codecov.io/gh/qiniu/goc/pull/191/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=qiniu#diff-Y21kL2luc3RhbGwuZ28=) | `62.06% <100.00%> (+1.35%)` | :arrow_up: |
| [pkg/cover/cover.go](https://codecov.io/gh/qiniu/goc/pull/191/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=qiniu#diff-cGtnL2NvdmVyL2NvdmVyLmdv) | `69.62% <100.00%> (+0.28%)` | :arrow_up: |
| [pkg/build/legacy.go](https://codecov.io/gh/qiniu/goc/pull/191/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=qiniu#diff-cGtnL2J1aWxkL2xlZ2FjeS5nbw==) | `94.11% <0.00%> (-5.89%)` | :arrow_down: |

codecov[bot]: # [Codecov](https://codecov.io/gh/qiniu/goc/pull/191?src=pr&el=h1&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=qiniu) Report
> Merging [#191](https://codecov.io/gh/qiniu/goc/pull/191?src=pr&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=qiniu) (5cc60e4) into [master](https://codecov.io/gh/qiniu/goc/commit/63c7438a635d4e707e823655fe9043cfcdeb7c2f?el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=qiniu) (63c7438) will **decrease** coverage by `0.10%`.
> The diff coverage is `71.42%`.

[![Impacted file tree graph](https://codecov.io/gh/qiniu/goc/pull/191/graphs/tree.svg?width=650&height=150&src=pr&token=7AHPDDLXQ3&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=qiniu)](https://codecov.io/gh/qiniu/goc/pull/191?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=qiniu)

```diff
@@            Coverage Diff             @@
##           master     #191      +/-   ##
==========================================
- Coverage   68.00%   67.90%   -0.11%     
==========================================
  Files          34       34              
  Lines        1738     1745       +7     
==========================================
+ Hits         1182     1185       +3     
- Misses        451      454       +3     
- Partials      105      106       +1     
```

| Flag | Coverage Δ | |
|---|---|---|
| e2e-1.11.x | `?` | |
| e2e-1.12.x | `?` | |
| e2e-1.13.x | `?` | |
| e2e-1.14.x | `?` | |
| e2e-1.15.x | `?` | |
| e2e-1.16.x | `?` | |
| unittest-1.13.x | `67.90% <71.42%> (+0.12%)` | :arrow_up: |
| unittest-1.14.x | `67.79% <71.42%> (+0.01%)` | :arrow_up: |
| unittest-1.15.x | `67.79% <71.42%> (-0.22%)` | :arrow_down: |
| unittest-1.16.x | `67.79% <71.42%> (+0.01%)` | :arrow_up: |

Flags with carried forward coverage won't be shown. [Click here](https://docs.codecov.io/docs/carryforward-flags?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=qiniu#carryforward-flags-in-the-pull-request-comment) to find out more.

| [Impacted Files](https://codecov.io/gh/qiniu/goc/pull/191?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=qiniu) | Coverage Δ | |
|---|---|---|
| [cmd/cover.go](https://codecov.io/gh/qiniu/goc/pull/191/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=qiniu#diff-Y21kL2NvdmVyLmdv) | `18.75% <0.00%> (-1.25%)` | :arrow_down: |
| [cmd/run.go](https://codecov.io/gh/qiniu/goc/pull/191/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=qiniu#diff-Y21kL3J1bi5nbw==) | `4.87% <0.00%> (-0.13%)` | :arrow_down: |
| [pkg/cover/instrument.go](https://codecov.io/gh/qiniu/goc/pull/191/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=qiniu#diff-cGtnL2NvdmVyL2luc3RydW1lbnQuZ28=) | `19.04% <ø> (ø)` | |
| [cmd/build.go](https://codecov.io/gh/qiniu/goc/pull/191/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=qiniu#diff-Y21kL2J1aWxkLmdv) | `63.33% <100.00%> (+1.26%)` | :arrow_up: |
| [cmd/commonflags.go](https://codecov.io/gh/qiniu/goc/pull/191/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=qiniu#diff-Y21kL2NvbW1vbmZsYWdzLmdv) | `93.93% <100.00%> (+0.18%)` | :arrow_up: |
| [cmd/install.go](https://codecov.io/gh/qiniu/goc/pull/191/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=qiniu#diff-Y21kL2luc3RhbGwuZ28=) | `62.06% <100.00%> (+1.35%)` | :arrow_up: |
| [pkg/cover/cover.go](https://codecov.io/gh/qiniu/goc/pull/191/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=qiniu#diff-cGtnL2NvdmVyL2NvdmVyLmdv) | `69.62% <100.00%> (+0.28%)` | :arrow_up: |
| [pkg/build/legacy.go](https://codecov.io/gh/qiniu/goc/pull/191/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=qiniu#diff-cGtnL2J1aWxkL2xlZ2FjeS5nbw==) | `94.11% <0.00%> (-5.89%)` | :arrow_down: |

codecov[bot]: # [Codecov](https://codecov.io/gh/qiniu/goc/pull/191?src=pr&el=h1&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=qiniu) Report
> Merging [#191](https://codecov.io/gh/qiniu/goc/pull/191?src=pr&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=qiniu) (5cc60e4) into [master](https://codecov.io/gh/qiniu/goc/commit/63c7438a635d4e707e823655fe9043cfcdeb7c2f?el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=qiniu) (63c7438) will **decrease** coverage by `0.10%`.
> The diff coverage is `71.42%`.

[![Impacted file tree graph](https://codecov.io/gh/qiniu/goc/pull/191/graphs/tree.svg?width=650&height=150&src=pr&token=7AHPDDLXQ3&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=qiniu)](https://codecov.io/gh/qiniu/goc/pull/191?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=qiniu)

```diff
@@            Coverage Diff             @@
##           master     #191      +/-   ##
==========================================
- Coverage   68.00%   67.90%   -0.11%     
==========================================
  Files          34       34              
  Lines        1738     1745       +7     
==========================================
+ Hits         1182     1185       +3     
- Misses        451      454       +3     
- Partials      105      106       +1     
```

| Flag | Coverage Δ | |
|---|---|---|
| e2e-1.11.x | `∅ <ø> (∅)` | |
| e2e-1.12.x | `∅ <ø> (∅)` | |
| e2e-1.13.x | `∅ <ø> (∅)` | |
| e2e-1.14.x | `∅ <ø> (∅)` | |
| e2e-1.15.x | `?` | |
| e2e-1.16.x | `?` | |
| unittest-1.13.x | `67.90% <71.42%> (+0.12%)` | :arrow_up: |
| unittest-1.14.x | `67.79% <71.42%> (+0.01%)` | :arrow_up: |
| unittest-1.15.x | `67.79% <71.42%> (-0.22%)` | :arrow_down: |
| unittest-1.16.x | `67.79% <71.42%> (+0.01%)` | :arrow_up: |

Flags with carried forward coverage won't be shown. [Click here](https://docs.codecov.io/docs/carryforward-flags?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=qiniu#carryforward-flags-in-the-pull-request-comment) to find out more.

| [Impacted Files](https://codecov.io/gh/qiniu/goc/pull/191?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=qiniu) | Coverage Δ | |
|---|---|---|
| [cmd/cover.go](https://codecov.io/gh/qiniu/goc/pull/191/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=qiniu#diff-Y21kL2NvdmVyLmdv) | `18.75% <0.00%> (-1.25%)` | :arrow_down: |
| [cmd/run.go](https://codecov.io/gh/qiniu/goc/pull/191/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=qiniu#diff-Y21kL3J1bi5nbw==) | `4.87% <0.00%> (-0.13%)` | :arrow_down: |
| [pkg/cover/instrument.go](https://codecov.io/gh/qiniu/goc/pull/191/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=qiniu#diff-cGtnL2NvdmVyL2luc3RydW1lbnQuZ28=) | `19.04% <ø> (ø)` | |
| [cmd/build.go](https://codecov.io/gh/qiniu/goc/pull/191/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=qiniu#diff-Y21kL2J1aWxkLmdv) | `63.33% <100.00%> (+1.26%)` | :arrow_up: |
| [cmd/commonflags.go](https://codecov.io/gh/qiniu/goc/pull/191/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=qiniu#diff-Y21kL2NvbW1vbmZsYWdzLmdv) | `93.93% <100.00%> (+0.18%)` | :arrow_up: |
| [cmd/install.go](https://codecov.io/gh/qiniu/goc/pull/191/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=qiniu#diff-Y21kL2luc3RhbGwuZ28=) | `62.06% <100.00%> (+1.35%)` | :arrow_up: |
| [pkg/cover/cover.go](https://codecov.io/gh/qiniu/goc/pull/191/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=qiniu#diff-cGtnL2NvdmVyL2NvdmVyLmdv) | `69.62% <100.00%> (+0.28%)` | :arrow_up: |
| [pkg/build/legacy.go](https://codecov.io/gh/qiniu/goc/pull/191/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=qiniu#diff-cGtnL2J1aWxkL2xlZ2FjeS5nbw==) | `94.11% <0.00%> (-5.89%)` | :arrow_down: |

codecov[bot]: # [Codecov](https://codecov.io/gh/qiniu/goc/pull/191?src=pr&el=h1&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=qiniu) Report
> Merging [#191](https://codecov.io/gh/qiniu/goc/pull/191?src=pr&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=qiniu) (5cc60e4) into [master](https://codecov.io/gh/qiniu/goc/commit/63c7438a635d4e707e823655fe9043cfcdeb7c2f?el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=qiniu) (63c7438) will **decrease** coverage by `0.10%`.
> The diff coverage is `71.42%`.

[![Impacted file tree graph](https://codecov.io/gh/qiniu/goc/pull/191/graphs/tree.svg?width=650&height=150&src=pr&token=7AHPDDLXQ3&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=qiniu)](https://codecov.io/gh/qiniu/goc/pull/191?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=qiniu)

```diff
@@            Coverage Diff             @@
##           master     #191      +/-   ##
==========================================
- Coverage   68.00%   67.90%   -0.11%     
==========================================
  Files          34       34              
  Lines        1738     1745       +7     
==========================================
+ Hits         1182     1185       +3     
- Misses        451      454       +3     
- Partials      105      106       +1     
```

| Flag | Coverage Δ | |
|---|---|---|
| e2e-1.11.x | `∅ <ø> (∅)` | |
| e2e-1.12.x | `∅ <ø> (∅)` | |
| e2e-1.13.x | `∅ <ø> (∅)` | |
| e2e-1.14.x | `∅ <ø> (∅)` | |
| e2e-1.15.x | `∅ <ø> (∅)` | |
| e2e-1.16.x | `∅ <ø> (∅)` | |
| unittest-1.13.x | `67.90% <71.42%> (+0.12%)` | :arrow_up: |
| unittest-1.14.x | `67.79% <71.42%> (+0.01%)` | :arrow_up: |
| unittest-1.15.x | `67.79% <71.42%> (-0.22%)` | :arrow_down: |
| unittest-1.16.x | `67.79% <71.42%> (+0.01%)` | :arrow_up: |

Flags with carried forward coverage won't be shown. [Click here](https://docs.codecov.io/docs/carryforward-flags?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=qiniu#carryforward-flags-in-the-pull-request-comment) to find out more.

| [Impacted Files](https://codecov.io/gh/qiniu/goc/pull/191?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=qiniu) | Coverage Δ | |
|---|---|---|
| [cmd/cover.go](https://codecov.io/gh/qiniu/goc/pull/191/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=qiniu#diff-Y21kL2NvdmVyLmdv) | `18.75% <0.00%> (-1.25%)` | :arrow_down: |
| [cmd/run.go](https://codecov.io/gh/qiniu/goc/pull/191/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=qiniu#diff-Y21kL3J1bi5nbw==) | `4.87% <0.00%> (-0.13%)` | :arrow_down: |
| [pkg/cover/instrument.go](https://codecov.io/gh/qiniu/goc/pull/191/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=qiniu#diff-cGtnL2NvdmVyL2luc3RydW1lbnQuZ28=) | `19.04% <ø> (ø)` | |
| [cmd/build.go](https://codecov.io/gh/qiniu/goc/pull/191/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=qiniu#diff-Y21kL2J1aWxkLmdv) | `63.33% <100.00%> (+1.26%)` | :arrow_up: |
| [cmd/commonflags.go](https://codecov.io/gh/qiniu/goc/pull/191/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=qiniu#diff-Y21kL2NvbW1vbmZsYWdzLmdv) | `93.93% <100.00%> (+0.18%)` | :arrow_up: |
| [cmd/install.go](https://codecov.io/gh/qiniu/goc/pull/191/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=qiniu#diff-Y21kL2luc3RhbGwuZ28=) | `62.06% <100.00%> (+1.35%)` | :arrow_up: |
| [pkg/cover/cover.go](https://codecov.io/gh/qiniu/goc/pull/191/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=qiniu#diff-cGtnL2NvdmVyL2NvdmVyLmdv) | `69.62% <100.00%> (+0.28%)` | :arrow_up: |
| [pkg/build/legacy.go](https://codecov.io/gh/qiniu/goc/pull/191/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=qiniu#diff-cGtnL2J1aWxkL2xlZ2FjeS5nbw==) | `94.11% <0.00%> (-5.89%)` | :arrow_down: |

codecov[bot]: # [Codecov](https://codecov.io/gh/qiniu/goc/pull/191?src=pr&el=h1&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=qiniu) Report
> Merging [#191](https://codecov.io/gh/qiniu/goc/pull/191?src=pr&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=qiniu) (5cc60e4) into [master](https://codecov.io/gh/qiniu/goc/commit/63c7438a635d4e707e823655fe9043cfcdeb7c2f?el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=qiniu) (63c7438) will **decrease** coverage by `0.10%`.
> The diff coverage is `71.42%`.

> :exclamation: Current head 5cc60e4 differs from pull request most recent head 41e9e6e. Consider uploading reports for the commit 41e9e6e to get more accurate results
[![Impacted file tree graph](https://codecov.io/gh/qiniu/goc/pull/191/graphs/tree.svg?width=650&height=150&src=pr&token=7AHPDDLXQ3&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=qiniu)](https://codecov.io/gh/qiniu/goc/pull/191?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=qiniu)

```diff
@@            Coverage Diff             @@
##           master     #191      +/-   ##
==========================================
- Coverage   68.00%   67.90%   -0.11%     
==========================================
  Files          34       34              
  Lines        1738     1745       +7     
==========================================
+ Hits         1182     1185       +3     
- Misses        451      454       +3     
- Partials      105      106       +1     
```

| Flag | Coverage Δ | |
|---|---|---|
| e2e-1.11.x | `∅ <ø> (∅)` | |
| e2e-1.12.x | `∅ <ø> (∅)` | |
| e2e-1.13.x | `∅ <ø> (∅)` | |
| e2e-1.14.x | `∅ <ø> (∅)` | |
| e2e-1.15.x | `∅ <ø> (∅)` | |
| e2e-1.16.x | `∅ <ø> (∅)` | |
| unittest-1.13.x | `67.90% <71.42%> (+0.12%)` | :arrow_up: |
| unittest-1.14.x | `67.79% <71.42%> (+0.01%)` | :arrow_up: |
| unittest-1.15.x | `67.79% <71.42%> (-0.22%)` | :arrow_down: |
| unittest-1.16.x | `67.79% <71.42%> (+0.01%)` | :arrow_up: |

Flags with carried forward coverage won't be shown. [Click here](https://docs.codecov.io/docs/carryforward-flags?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=qiniu#carryforward-flags-in-the-pull-request-comment) to find out more.

| [Impacted Files](https://codecov.io/gh/qiniu/goc/pull/191?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=qiniu) | Coverage Δ | |
|---|---|---|
| [cmd/cover.go](https://codecov.io/gh/qiniu/goc/pull/191/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=qiniu#diff-Y21kL2NvdmVyLmdv) | `18.75% <0.00%> (-1.25%)` | :arrow_down: |
| [cmd/run.go](https://codecov.io/gh/qiniu/goc/pull/191/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=qiniu#diff-Y21kL3J1bi5nbw==) | `4.87% <0.00%> (-0.13%)` | :arrow_down: |
| [pkg/cover/instrument.go](https://codecov.io/gh/qiniu/goc/pull/191/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=qiniu#diff-cGtnL2NvdmVyL2luc3RydW1lbnQuZ28=) | `19.04% <ø> (ø)` | |
| [cmd/build.go](https://codecov.io/gh/qiniu/goc/pull/191/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=qiniu#diff-Y21kL2J1aWxkLmdv) | `63.33% <100.00%> (+1.26%)` | :arrow_up: |
| [cmd/commonflags.go](https://codecov.io/gh/qiniu/goc/pull/191/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=qiniu#diff-Y21kL2NvbW1vbmZsYWdzLmdv) | `93.93% <100.00%> (+0.18%)` | :arrow_up: |
| [cmd/install.go](https://codecov.io/gh/qiniu/goc/pull/191/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=qiniu#diff-Y21kL2luc3RhbGwuZ28=) | `62.06% <100.00%> (+1.35%)` | :arrow_up: |
| [pkg/cover/cover.go](https://codecov.io/gh/qiniu/goc/pull/191/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=qiniu#diff-cGtnL2NvdmVyL2NvdmVyLmdv) | `69.62% <100.00%> (+0.28%)` | :arrow_up: |
| [pkg/build/legacy.go](https://codecov.io/gh/qiniu/goc/pull/191/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=qiniu#diff-cGtnL2J1aWxkL2xlZ2FjeS5nbw==) | `94.11% <0.00%> (-5.89%)` | :arrow_down: |


Patch:
diff --git a/cmd/build.go b/cmd/build.go
index eb4a54b..26b14bb 100644
--- a/cmd/build.go
+++ b/cmd/build.go
@@ -78,6 +78,7 @@ func runBuild(args []string, wd string) {
 		Mode:                     coverMode.String(),
 		AgentPort:                agentPort.String(),
 		Center:                   center,
+		Singleton:                singleton,
 		IsMod:                    gocBuild.IsMod,
 		ModRootPath:              gocBuild.ModRootPath,
 		OneMainPackage:           true, // it is a go build
diff --git a/cmd/commonflags.go b/cmd/commonflags.go
index 9440276..7f3a6d1 100644
--- a/cmd/commonflags.go
+++ b/cmd/commonflags.go
@@ -31,6 +31,7 @@ var (
 	debugGoc          bool
 	debugInCISyncFile string
 	buildFlags        string
+	singleton         bool
 
 	goRunExecFlag  string
 	goRunArguments string
@@ -51,6 +52,7 @@ func addCommonFlags(cmdset *pflag.FlagSet) {
 	addBasicFlags(cmdset)
 	cmdset.Var(&coverMode, "mode", "coverage mode: set, count, atomic")
 	cmdset.Var(&agentPort, "agentport", "a fixed port such as :8100 for registered service communicate with goc server. if not provided, using a random one")
+	cmdset.BoolVar(&singleton, "singleton", false, "singleton mode, not register to goc center")
 	cmdset.StringVar(&buildFlags, "buildflags", "", "specify the build flags")
 	// bind to viper
 	viper.BindPFlags(cmdset)
diff --git a/cmd/cover.go b/cmd/cover.go
index dec4e5b..133d39d 100644
--- a/cmd/cover.go
+++ b/cmd/cover.go
@@ -38,22 +38,25 @@ goc cover --center=http://127.0.0.1:7777 --target=/path/to/target --mode=atomic
 `,
 	Hidden: true,
 	Run: func(cmd *cobra.Command, args []string) {
-		var buildFlags string
-		buildFlags = viper.GetString("buildflags")
-
-		ci := &cover.CoverInfo{
-			Args:           buildFlags,
-			GoPath:         "",
-			Target:         target,
-			Mode:           coverMode.String(),
-			AgentPort:      agentPort.String(),
-			Center:         center,
-			OneMainPackage: false,
-		}
-		_ = cover.Execute(ci)
+		runCover(target)
 	},
 }
 
+func runCover(target string) {
+	buildFlags := viper.GetString("buildflags")
+	ci := &cover.CoverInfo{
+		Args:           buildFlags,
+		GoPath:         "",
+		Target:         target,
+		Mode:           coverMode.String(),
+		AgentPort:      agentPort.String(),
+		Center:         center,
+		Singleton:      singleton,
+		OneMainPackage: false,
+	}
+	_ = cover.Execute(ci)
+}
+
 func init() {
 	coverCmd.Flags().StringVar(&target, "target", ".", "target folder to cover")
 	addCommonFlags(coverCmd.Flags())
diff --git a/cmd/install.go b/cmd/install.go
index 5d84569..edc3c57 100644
--- a/cmd/install.go
+++ b/cmd/install.go
@@ -71,6 +71,7 @@ func runInstall(args []string, wd string) {
 		Mode:                     coverMode.String(),
 		AgentPort:                agentPort.String(),
 		Center:                   center,
+		Singleton:                singleton,
 		IsMod:                    gocBuild.IsMod,
 		ModRootPath:              gocBuild.ModRootPath,
 		OneMainPackage:           false,
diff --git a/cmd/run.go b/cmd/run.go
index f78207c..6fde9ce 100644
--- a/cmd/run.go
+++ b/cmd/run.go
@@ -70,6 +70,7 @@ goc run . [--buildflags] [--exec] [--arguments]
 			Target:                   gocBuild.TmpDir,
 			Mode:                     coverMode.String(),
 			Center:                   gocServer,
+			Singleton:                singleton,
 			AgentPort:                "",
 			IsMod:                    gocBuild.IsMod,
 			ModRootPath:              gocBuild.ModRootPath,
diff --git a/pkg/cover/cover.go b/pkg/cover/cover.go
index 742e352..2639ce2 100644
--- a/pkg/cover/cover.go
+++ b/pkg/cover/cover.go
@@ -52,6 +52,7 @@ type TestCover struct {
 	Mode                     string
 	AgentPort                string
 	Center                   string // cover profile host center
+	Singleton                bool
 	MainPkgCover             *PackageCover
 	DepsCover                []*PackageCover
 	CacheCover               map[string]*PackageCover
@@ -139,6 +140,7 @@ type CoverInfo struct {
 	Mode                     string
 	AgentPort                string
 	Center                   string
+	Singleton                bool
 }
 
 //Execute inject cover variables for all the .go files in the target folder
@@ -150,6 +152,7 @@ func Execute(coverInfo *CoverInfo) error {
 	mode := coverInfo.Mode
 	agentPort := coverInfo.AgentPort
 	center := coverInfo.Center
+	singleton := coverInfo.Singleton
 	globalCoverVarImportPath := coverInfo.GlobalCoverVarImportPath
 
 	if coverInfo.IsMod {
@@ -187,6 +190,7 @@ func Execute(coverInfo *CoverInfo) error {
 				Mode:                     mode,
 				AgentPort:                agentPort,
 				Center:                   center,
+				Singleton:                singleton,
 				MainPkgCover:             mainCover,
 				GlobalCoverVarImportPath: globalCoverVarImportPath,
 			}
diff --git a/pkg/cover/instrument.go b/pkg/cover/instrument.go
index 4719e8f..a559fea 100644
--- a/pkg/cover/instrument.go
+++ b/pkg/cover/instrument.go
@@ -131,11 +131,15 @@ func clearFileCover(counter []uint32) {
 }
 
 func registerHandlers() {
+	{{if .Singleton}}
+	ln, _, err := listen()
+	{{else}}
 	ln, host, err := listen()
+	{{end}}
 	if err != nil {
 		log.Fatalf("listen failed, err:%v", err)
 	}
-	
+	{{if not .Singleton}}
 	profileAddr := "http://" + host
 	if resp, err := registerSelf(profileAddr); err != nil {
 		log.Fatalf("register address %v failed, err: %v, response: %v", profileAddr, err, string(resp))
@@ -157,6 +161,7 @@ func registerHandlers() {
 		deregisterSelf(profileAddrs)
 	}
 	go watchSignal(fn)
+	{{end}}
 
 	mux := http.NewServeMux()
 	// Coverage reports the current code coverage as a fraction in the range [0, 1].


Test patch:
diff --git a/cmd/cover_test.go b/cmd/cover_test.go
new file mode 100644
index 0000000..c97dbb1
--- /dev/null
+++ b/cmd/cover_test.go
@@ -0,0 +1,54 @@
+package cmd
+
+import (
+	"os"
+	"path/filepath"
+	"testing"
+
+	"github.com/stretchr/testify/assert"
+)
+
+var mainContent = []byte(`package main
+
+import (
+	"fmt"
+)
+
+func main() {
+	fmt.Println("hello world")
+}`)
+
+var goModContent = []byte(`module example.com/simple-project
+
+go 1.11
+`)
+
+func TestCoverSuccess(t *testing.T) {
+	workingDir := filepath.Join(baseDir, "../tests/samples/tmp/project")
+	err := os.MkdirAll(workingDir, os.ModePerm)
+	assert.NoError(t, err)
+	defer os.RemoveAll(workingDir)
+
+	err = writeFile(workingDir+"/main.go", mainContent)
+	assert.NoError(t, err)
+	err = writeFile(workingDir+"/go.mod", goModContent)
+	assert.NoError(t, err)
+	os.Setenv("GO111MODULE", "on")
+
+	runCover(workingDir)
+
+	_, err = os.Lstat(workingDir + "/http_cover_apis_auto_generated.go")
+	assert.Equal(t, err, nil, "the generate file should be generated.")
+}
+
+func writeFile(name string, data []byte) error {
+	f, err := os.OpenFile(name, os.O_WRONLY|os.O_CREATE|os.O_TRUNC, 0644)
+	if err != nil {
+		return err
+	}
+	_, err = f.Write(data)
+	if err1 := f.Close(); err1 != nil && err == nil {
+		err = err1
+	}
+	return err
+}
diff --git a/tests/build.bats b/tests/build.bats
index 055d8c6..35d5d78 100755
--- a/tests/build.bats
+++ b/tests/build.bats
@@ -112,4 +112,17 @@ setup() {
     [ "$status" -eq 0 ]
 
     wait $profile_pid
-}
\ No newline at end of file
+}
+
+@test "test basic goc build command with singleton" {
+    cd samples/run_for_several_seconds
+    
+    wait_profile_backend "build7" &
+    profile_pid=$!
+
+    run gocc build --debug --singleton --debugcisyncfile ci-sync.bak;
+    info build7 output: $output
+    [ "$status" -eq 0 ]
+
+    wait $profile_pid
+}