Replace github.com/unknwon/com with stdlib and internal helpers (#8148)

Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Co-authored-by: Joe Chen <jc@unknwon.io>
Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
Copilot
2026-02-05 22:08:54 -05:00
committed by GitHub
parent 6d56105f8f
commit bf17cc6c69
38 changed files with 259 additions and 171 deletions

View File

@@ -9,18 +9,19 @@ import (
"os"
"path"
"path/filepath"
"strconv"
"strings"
"sync"
"time"
"github.com/cockroachdb/errors"
"github.com/unknwon/com"
"golang.org/x/crypto/ssh"
log "unknwon.dev/clog/v2"
"xorm.io/xorm"
"gogs.io/gogs/internal/conf"
"gogs.io/gogs/internal/errutil"
"gogs.io/gogs/internal/osutil"
"gogs.io/gogs/internal/process"
)
@@ -210,7 +211,8 @@ func SSHKeygenParsePublicKey(key, keyTestPath, keygenPath string) (string, int,
}
keyType := strings.Trim(fields[len(fields)-1], "()\r\n")
return strings.ToLower(keyType), com.StrTo(fields[0]).MustInt(), nil
length, _ := strconv.Atoi(fields[0])
return strings.ToLower(keyType), length, nil
}
// SSHNativeParsePublicKey extracts the key type and length using the golang SSH library.
@@ -540,7 +542,7 @@ func RewriteAuthorizedKeys() error {
return err
}
if com.IsExist(fpath) {
if osutil.Exist(fpath) {
if err = os.Remove(fpath); err != nil {
return err
}