github.com/shogo82148/std@v1.22.1-0.20240327122250-4e474527810c/internal/coverage/encodemeta/encode.go (about)

     1  // Copyright 2021 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 encodemeta
     6  
     7  import (
     8  	"github.com/shogo82148/std/hash"
     9  	"github.com/shogo82148/std/internal/coverage"
    10  	"github.com/shogo82148/std/internal/coverage/stringtab"
    11  	"github.com/shogo82148/std/io"
    12  )
    13  
    14  type CoverageMetaDataBuilder struct {
    15  	stab    stringtab.Writer
    16  	funcs   []funcDesc
    17  	tmp     []byte
    18  	h       hash.Hash
    19  	pkgpath uint32
    20  	pkgname uint32
    21  	modpath uint32
    22  	debug   bool
    23  	werr    error
    24  }
    25  
    26  func NewCoverageMetaDataBuilder(pkgpath string, pkgname string, modulepath string) (*CoverageMetaDataBuilder, error)
    27  
    28  // AddFunc registers a new function with the meta data builder.
    29  func (b *CoverageMetaDataBuilder) AddFunc(f coverage.FuncDesc) uint
    30  
    31  // Emit writes the meta-data accumulated so far in this builder to 'w'.
    32  // Returns a hash of the meta-data payload and an error.
    33  func (b *CoverageMetaDataBuilder) Emit(w io.WriteSeeker) ([16]byte, error)
    34  
    35  // HashFuncDesc computes an md5 sum of a coverage.FuncDesc and returns
    36  // a digest for it.
    37  func HashFuncDesc(f *coverage.FuncDesc) [16]byte