buildid

package standard library
go1.18.10 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jan 10, 2023 License: BSD-3-Clause Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func FindAndHash

func FindAndHash(r io.Reader, id string, bufSize int) (matches []int64, hash [32]byte, err error)

FindAndHash reads all of r and returns the offsets of occurrences of id. While reading, findAndHash also computes and returns a hash of the content of r, but with occurrences of id replaced by zeros. FindAndHash reads bufSize bytes from r at a time. If bufSize == 0, FindAndHash uses a reasonable default.

func HashToString

func HashToString(h [32]byte) string

HashToString converts the hash h to a string to be recorded in package archives and binaries as part of the build ID. We use the first 120 bits of the hash (5 chunks of 24 bits each) and encode it in base64, resulting in a 20-byte string. Because this is only used for detecting the need to rebuild installed files (not for lookups in the object file cache), 120 bits are sufficient to drive the probability of a false "do not need to rebuild" decision to effectively zero. We embed two different hashes in archives and four in binaries, so cutting to 20 bytes is a significant savings when build IDs are displayed. (20*4+3 = 83 bytes compared to 64*4+3 = 259 bytes for the more straightforward option of printing the entire h in base64).

func ReadELFNote

func ReadELFNote(filename, name string, typ int32) ([]byte, error)

func ReadFile

func ReadFile(name string) (id string, err error)

ReadFile reads the build ID from an archive or executable file.

func Rewrite

func Rewrite(w io.WriterAt, pos []int64, id string) error

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL