Documentation ¶
Index ¶
- func FindAndHash(r io.Reader, id string, bufSize int) (matches []int64, hash [32]byte, err error)
- func HashToString(h [32]byte) string
- func ReadELFNote(filename, name string, typ int32) ([]byte, error)
- func ReadFile(name string) (id string, err error)
- func Rewrite(w io.WriterAt, pos []int64, id string) error
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func FindAndHash ¶
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 ¶
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).
Types ¶
This section is empty.