MCPcopy Create free account
hub / github.com/Code-Hex/pget / get2md5

Function get2md5

pget_test.go:103–120  ·  view source on GitHub ↗
(path string)

Source from the content-addressed store, hash-verified

101}
102
103func get2md5(path string) (string, error) {
104 f, err := os.Open(path)
105 if err != nil {
106 return "", err
107 }
108
109 defer f.Close()
110
111 hash := md5.New()
112 if _, err := io.Copy(hash, f); err != nil {
113 return "", err
114 }
115
116 // get the 16 bytes hash
117 bytes := hash.Sum(nil)[:16]
118
119 return hex.EncodeToString(bytes), nil
120}
121
122func cmpFileChecksum(t *testing.T, wantPath, gotPath string) {
123 t.Helper()

Callers 1

cmpFileChecksumFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected