files, upload下文件过多

https://github.com/leanote/leanote/issues/225
This commit is contained in:
lealife
2015-10-10 14:12:22 +08:00
parent 62bc74d3c6
commit da7d31fa00
4 changed files with 78 additions and 40 deletions

View File

@ -23,6 +23,22 @@ func Md5(s string) string {
return hex.EncodeToString(h.Sum(nil))
}
// 3位数的转换, 为了用bson.id -> 3位数
func Digest3(str string) string {
var b rune = 0
for _, k := range str {
b += k
}
return fmt.Sprintf("%d", b % 1000)
}
func Digest2(str string) string {
var b rune = 0
for _, k := range str {
b += k
}
return fmt.Sprintf("%d", b % 100)
}
// Guid
func NewGuid() string {
b := make([]byte, 48)