extend/util/util.go
@@ -3,6 +3,8 @@ import ( "archive/zip" "bytes" "crypto/md5" "encoding/hex" "encoding/json" "image" "io" @@ -310,3 +312,19 @@ fmtStr := "%0"+strconv.Itoa(m)+"d" return fmt.Sprintf(fmtStr, n) } func FileMd5(path string) (string,error){ file, err := os.Open(path) if err !=nil { return "",err } defer file.Close() _md5 := md5.New() if _,err := io.Copy(_md5, file);err != nil { return "",err } return hex.EncodeToString(_md5.Sum(nil)),nil }