github.com/mtsmfm/go/src@v0.0.0-20221020090648-44bdcb9f8fde/internal/coverage/cmddefs.go (about)

     1  // Copyright 2022 The Go Authors. All rights reserved.
     2  // Use of this source code is governed by a BSD-style
     3  // license that can be found in the LICENSE file.
     4  
     5  package coverage
     6  
     7  // CoverPkgConfig is a bundle of information passed from the Go
     8  // command to the cover command during "go build -cover" runs. The
     9  // Go command creates and fills in a struct as below, then passes
    10  // file containing the encoded JSON for the struct to the "cover"
    11  // tool when instrumenting the source files in a Go package.
    12  type CoverPkgConfig struct {
    13  	// File into which cmd/cover should emit summary info
    14  	// when instrumentation is complete.
    15  	OutConfig string
    16  
    17  	// Import path for the package being instrumented.
    18  	PkgPath string
    19  
    20  	// Package name.
    21  	PkgName string
    22  
    23  	// Instrumentation granularity: one of "perfunc" or "perblock" (default)
    24  	Granularity string
    25  
    26  	// Module path for this package (empty if no go.mod in use)
    27  	ModulePath string
    28  }
    29  
    30  // CoverFixupConfig contains annotations/notes generated by the
    31  // cmd/cover tool (during instrumentation) to be passed on to the
    32  // compiler when the instrumented code is compiled. The cmd/cover tool
    33  // creates a struct of this type, JSON-encodes it, and emits the
    34  // result to a file, which the Go command then passes to the compiler
    35  // when the instrumented package is built.
    36  type CoverFixupConfig struct {
    37  	// Name of the variable (created by cmd/cover) containing the
    38  	// encoded meta-data for the package.
    39  	MetaVar string
    40  
    41  	// Length of the meta-data.
    42  	MetaLen int
    43  
    44  	// Hash computed by cmd/cover of the meta-data.
    45  	MetaHash string
    46  
    47  	// Instrumentation strategy. For now this is always set to
    48  	// "normal", but in the future we may add new values (for example,
    49  	// if panic paths are instrumented, or if the instrumenter
    50  	// eliminates redundant counters).
    51  	Strategy string
    52  
    53  	// Prefix assigned to the names of counter variables generated
    54  	// during instrumentation by cmd/cover.
    55  	CounterPrefix string
    56  
    57  	// Name chosen for the package ID variable generated during
    58  	// instrumentation.
    59  	PkgIdVar string
    60  
    61  	// Counter mode (e.g. set/count/atomic)
    62  	CounterMode string
    63  
    64  	// Counter granularity (perblock or perfunc).
    65  	CounterGranularity string
    66  }