liuxiaolong
2020-01-06 2fdef0f732a5d6549d2c42a116dfdd3dc75a0b48
extend/util/util.go
@@ -3,6 +3,8 @@
import (
   "archive/zip"
   "bytes"
   "crypto/md5"
   "encoding/hex"
   "encoding/json"
   "image"
   "io"
@@ -16,7 +18,6 @@
   "basic.com/pubsub/protomsg.git"
   "github.com/gin-gonic/gin"
   "github.com/golang/glog"
   "github.com/pierrec/lz4"
   "gocv.io/x/gocv"
@@ -41,7 +42,6 @@
// ResponseFormat 返回数据格式化
func ResponseFormat(c *gin.Context, respStatus *code.Code, data interface{}) {
   if respStatus == nil {
      glog.Error("response status param not found!")
      respStatus = code.RequestParamError
   }
   c.JSON(respStatus.Status, gin.H{
@@ -309,4 +309,20 @@
   }
   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
}