github.com/shogo82148/std@v1.22.1-0.20240327122250-4e474527810c/cmd/internal/buildid/buildid.go (about)

     1  // Copyright 2017 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 buildid
     6  
     7  // ReadFile reads the build ID from an archive or executable file.
     8  func ReadFile(name string) (id string, err error)
     9  
    10  // HashToString converts the hash h to a string to be recorded
    11  // in package archives and binaries as part of the build ID.
    12  // We use the first 120 bits of the hash (5 chunks of 24 bits each) and encode
    13  // it in base64, resulting in a 20-byte string. Because this is only used for
    14  // detecting the need to rebuild installed files (not for lookups
    15  // in the object file cache), 120 bits are sufficient to drive the
    16  // probability of a false "do not need to rebuild" decision to effectively zero.
    17  // We embed two different hashes in archives and four in binaries,
    18  // so cutting to 20 bytes is a significant savings when build IDs are displayed.
    19  // (20*4+3 = 83 bytes compared to 64*4+3 = 259 bytes for the
    20  // more straightforward option of printing the entire h in base64).
    21  func HashToString(h [32]byte) string