| | |
| | | import ( |
| | | "archive/zip" |
| | | "bytes" |
| | | "crypto/md5" |
| | | "encoding/hex" |
| | | "encoding/json" |
| | | "image" |
| | | "io" |
| | |
| | | |
| | | "basic.com/pubsub/protomsg.git" |
| | | "github.com/gin-gonic/gin" |
| | | "github.com/golang/glog" |
| | | "github.com/pierrec/lz4" |
| | | "gocv.io/x/gocv" |
| | | |
| | |
| | | // 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{ |
| | |
| | | } |
| | | |
| | | 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 |
| | | } |