diff options
author | 6543 <6543@obermui.de> | 2020-12-25 09:59:32 +0000 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-12-25 11:59:32 +0200 |
commit | a19447aed128ecadfcd938d6a80cd4951af1f4ce (patch) | |
tree | 6312bf946d601aab29731645a4777feeaea66036 /modules/base | |
parent | 04ae0f2f3f4556c6d0b4adc5f2cffd0cc7d25151 (diff) | |
download | gitea-a19447aed128ecadfcd938d6a80cd4951af1f4ce.tar.gz gitea-a19447aed128ecadfcd938d6a80cd4951af1f4ce.zip |
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
Diffstat (limited to 'modules/base')
-rw-r--r-- | modules/base/tool.go | 9 |
1 files changed, 4 insertions, 5 deletions
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 } |