From c2f8c24f1ddb67f890f9ac4af5328e65a46aab75 Mon Sep 17 00:00:00 2001
From: liuxiaolong <736321739@qq.com>
Date: 星期五, 20 十二月 2019 16:35:46 +0800
Subject: [PATCH] test

---
 extend/util/util.go |   31 +++++++++++++++++++++++++++++++
 1 files changed, 31 insertions(+), 0 deletions(-)

diff --git a/extend/util/util.go b/extend/util/util.go
index 845ff42..89fc165 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"
@@ -296,4 +298,33 @@
 	}
 
 	return nil
+}
+
+func FormatNum(oNum int,n int) string {
+	m := 0
+	for {
+		oNum = oNum / 10
+		m++
+		if oNum == 0 {
+			break
+		}
+	}
+	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