package db import ( "crypto/md5" "fmt" "io" "os" ) // fileMD5 calculates the MD5 hash of a file. func fileMD5(path string) (string, error) { file, err := os.Open(path) if err != nil { return "", err } defer func() { if err := file.Close(); err != nil { fmt.Printf("Error closing file: %v\n", err) } }() hash := md5.New() if _, err := io.Copy(hash, file); err != nil { return "", err } return fmt.Sprintf("%x", hash.Sum(nil)), nil }