From a19447aed128ecadfcd938d6a80cd4951af1f4ce Mon Sep 17 00:00:00 2001 From: 6543 <6543@obermui.de> Date: Fri, 25 Dec 2020 09:59:32 +0000 Subject: migrate from com.* to alternatives (#14103) * remove github.com/unknwon/com from models * dont use "com.ToStr()" * replace "com.ToStr" with "fmt.Sprint" where its easy to do * more refactor * fix test * just "proxy" Copy func for now * as per @lunny --- modules/base/tool.go | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) (limited to 'modules/base') diff --git a/modules/base/tool.go b/modules/base/tool.go index 00b13f76c7..7ac572b85b 100644 --- a/modules/base/tool.go +++ b/modules/base/tool.go @@ -26,7 +26,6 @@ import ( "code.gitea.io/gitea/modules/setting" "github.com/dustin/go-humanize" - "github.com/unknwon/com" ) // EncodeMD5 encodes string to md5 hex value. @@ -86,8 +85,8 @@ func VerifyTimeLimitCode(data string, minutes int, code string) bool { // split code start := code[:12] lives := code[12:18] - if d, err := com.StrTo(lives).Int(); err == nil { - minutes = d + if d, err := strconv.ParseInt(lives, 10, 0); err == nil { + minutes = int(d) } // right active code @@ -131,7 +130,7 @@ func CreateTimeLimitCode(data string, minutes int, startInf interface{}) string // create sha1 encode string sh := sha1.New() - _, _ = sh.Write([]byte(data + setting.SecretKey + startStr + endStr + com.ToStr(minutes))) + _, _ = sh.Write([]byte(fmt.Sprintf("%s%s%s%s%d", data, setting.SecretKey, startStr, endStr, minutes))) encoded := hex.EncodeToString(sh.Sum(nil)) code := fmt.Sprintf("%s%06d%s", startStr, minutes, encoded) @@ -223,7 +222,7 @@ func TruncateString(str string, limit int) string { func StringsToInt64s(strs []string) ([]int64, error) { ints := make([]int64, len(strs)) for i := range strs { - n, err := com.StrTo(strs[i]).Int64() + n, err := strconv.ParseInt(strs[i], 10, 64) if err != nil { return ints, err } -- cgit v1.2.3