MCPcopy Index your code
hub / github.com/cloudnative-pg/cloudnative-pg / GetByName

Function GetByName

pkg/executablehash/executablehash.go:78–94  ·  view source on GitHub ↗

GetByName gets the hashcode of a binary given its filename

(name string)

Source from the content-addressed store, hash-verified

76
77// GetByName gets the hashcode of a binary given its filename
78func GetByName(name string) (string, error) {
79 binaryFileStream, err := StreamByName(name)
80 if err != nil {
81 return "", err
82 }
83 defer func() {
84 err = binaryFileStream.Close()
85 }()
86
87 encoder := sha256.New()
88 _, err = io.Copy(encoder, binaryFileStream)
89 if err != nil {
90 return "", err
91 }
92
93 return fmt.Sprintf("%x", encoder.Sum(nil)), err
94}

Callers 1

Calls 2

StreamByNameFunction · 0.85
CloseMethod · 0.65

Tested by

no test coverage detected