forked from forgejo/forgejo
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
This commit is contained in:
parent
04ae0f2f3f
commit
a19447aed1
46 changed files with 230 additions and 220 deletions
|
@ -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
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue