Source File
coverage.go
Belonging Package
runtime/coverage
// Copyright 2022 The Go Authors. All rights reserved.// Use of this source code is governed by a BSD-style// license that can be found in the LICENSE file.// Package coverage contains APIs for writing coverage profile data at runtime// from long-running and/or server programs that do not terminate via [os.Exit].package coverageimport ()// initHook is invoked from main.init in programs built with -cover.// The call is emitted by the compiler.func initHook( bool) {cfile.InitHook()}// 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).func ( string) error {return cfile.WriteMetaDir()}// 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).func ( io.Writer) error {return cfile.WriteMeta()}// 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.func ( string) error {return cfile.WriteCountersDir()}// 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.func ( io.Writer) error {return cfile.WriteCounters()}// 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).func () error {return cfile.ClearCounters()}
![]() |
The pages are generated with Golds v0.7.9-preview. (GOOS=linux GOARCH=amd64) Golds is a Go 101 project developed by Tapir Liu. PR and bug reports are welcome and can be submitted to the issue list. Please follow @zigo_101 (reachable from the left QR code) to get the latest news of Golds. |