MCPcopy Create free account
hub / github.com/codehamr/codehamr / hashFile

Function hashFile

internal/update/update.go:103–114  ·  view source on GitHub ↗

hashFile streams a file through sha256.

(path string)

Source from the content-addressed store, hash-verified

101
102// hashFile streams a file through sha256.
103func hashFile(path string) (string, error) {
104 f, err := os.Open(path)
105 if err != nil {
106 return "", err
107 }
108 defer f.Close()
109 h := sha256.New()
110 if _, err := io.Copy(h, f); err != nil {
111 return "", err
112 }
113 return hex.EncodeToString(h.Sum(nil)), nil
114}
115
116// Apply downloads the current platform's binary, verifies its sha256 against the
117// published codehamr_checksums.txt, and atomically replaces execPath. The caller

Callers 1

CheckFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected