From 2fdef0f732a5d6549d2c42a116dfdd3dc75a0b48 Mon Sep 17 00:00:00 2001 From: liuxiaolong <736321739@qq.com> Date: 星期一, 06 一月 2020 16:25:34 +0800 Subject: [PATCH] merge ynPatch --- extend/util/util.go | 20 ++++++++++++++++++-- 1 files changed, 18 insertions(+), 2 deletions(-) diff --git a/extend/util/util.go b/extend/util/util.go index 224d086..555bc37 100644 --- a/extend/util/util.go +++ b/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 } \ No newline at end of file -- Gitblit v1.8.0