Answers for "golang calculate md5 of a file"

Go
1

golang get file md5

f, err := os.Open("path/to/file")
if err != nil {
	log.Fatal(err)
}

defer f.Close()
h := md5.New()
if _, err := io.Copy(h, f); err != nil {
	log.Fatal(err)
}
fmt.Printf("%x", h.Sum(nil))
Posted by: Guest on July-06-2020

Browse Popular Code Answers by Language