summaryrefslogtreecommitdiff
path: root/devdocs/go/runtime%2Fcoverage%2Findex.html
blob: f62b083b3c30ff02c5887d03115203e62bbf5455 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
<h1> Package coverage  </h1>     <ul id="short-nav">
<li><code>import "runtime/coverage"</code></li>
<li><a href="#pkg-overview" class="overviewLink">Overview</a></li>
<li><a href="#pkg-index" class="indexLink">Index</a></li>
</ul>     <h2 id="pkg-overview">Overview </h2>      <h2 id="pkg-index">Index </h2>  <ul id="manual-nav">
<li><a href="#ClearCounters">func ClearCounters() error</a></li>
<li><a href="#WriteCounters">func WriteCounters(w io.Writer) error</a></li>
<li><a href="#WriteCountersDir">func WriteCountersDir(dir string) error</a></li>
<li><a href="#WriteMeta">func WriteMeta(w io.Writer) error</a></li>
<li><a href="#WriteMetaDir">func WriteMetaDir(dir string) error</a></li>
</ul> <h3>Package files</h3> <p>  <span>apis.go</span> <span>emit.go</span> <span>hooks.go</span> <span>testsupport.go</span>  </p>   <h2 id="ClearCounters">func <span>ClearCounters</span>  <span title="Added in Go 1.20">1.20</span> </h2> <pre data-language="go">func ClearCounters() error</pre> <p>ClearCounters clears/resets all coverage counter variables in the currently running program. It returns an error if the program in question was not built with the "-cover" flag. Clearing of coverage counters is also not supported for programs not using atomic counter mode (see more detailed comments below for the rationale here). </p>
<h2 id="WriteCounters">func <span>WriteCounters</span>  <span title="Added in Go 1.20">1.20</span> </h2> <pre data-language="go">func WriteCounters(w io.Writer) error</pre> <p>WriteCounters writes coverage counter-data content for the currently running program to the writer 'w'. An error will be returned if the operation can't be completed successfully (for example, if the currently running program was not built with "-cover", or if a write fails). The counter data written will be a snapshot taken at the point of the invocation. </p>
<h2 id="WriteCountersDir">func <span>WriteCountersDir</span>  <span title="Added in Go 1.20">1.20</span> </h2> <pre data-language="go">func WriteCountersDir(dir string) error</pre> <p>WriteCountersDir writes a coverage counter-data file for the currently running program to the directory specified in 'dir'. An error will be returned if the operation can't be completed successfully (for example, if the currently running program was not built with "-cover", or if the directory does not exist). The counter data written will be a snapshot taken at the point of the call. </p>
<h2 id="WriteMeta">func <span>WriteMeta</span>  <span title="Added in Go 1.20">1.20</span> </h2> <pre data-language="go">func WriteMeta(w io.Writer) error</pre> <p>WriteMeta writes the meta-data content (the payload that would normally be emitted to a meta-data file) for the currently running program to the writer 'w'. An error will be returned if the operation can't be completed successfully (for example, if the currently running program was not built with "-cover", or if a write fails). </p>
<h2 id="WriteMetaDir">func <span>WriteMetaDir</span>  <span title="Added in Go 1.20">1.20</span> </h2> <pre data-language="go">func WriteMetaDir(dir string) error</pre> <p>WriteMetaDir writes a coverage meta-data file for the currently running program to the directory specified in 'dir'. An error will be returned if the operation can't be completed successfully (for example, if the currently running program was not built with "-cover", or if the directory does not exist). </p><div class="_attribution">
  <p class="_attribution-p">
    &copy; Google, Inc.<br>Licensed under the Creative Commons Attribution License 3.0.<br>
    <a href="http://golang.org/pkg/runtime/coverage/" class="_attribution-link">http://golang.org/pkg/runtime/coverage/</a>
  </p>
</div>