refactor: extract path logic to path.go and run go fmt on codebase
This commit is contained in:
@@ -34,14 +34,14 @@ func CompressToBase64(data string) (string, error) {
|
||||
var buf bytes.Buffer
|
||||
zw := GetZlibWriter(&buf)
|
||||
defer PutZlibWriter(zw)
|
||||
|
||||
|
||||
if _, err := zw.Write([]byte(data)); err != nil {
|
||||
return "", err
|
||||
}
|
||||
if err := zw.Close(); err != nil {
|
||||
return "", err
|
||||
}
|
||||
|
||||
|
||||
return base64.StdEncoding.EncodeToString(buf.Bytes()), nil
|
||||
}
|
||||
|
||||
|
||||
@@ -41,7 +41,7 @@ func Encrypt(plaintext string) (string, error) {
|
||||
if !IsSecretKeySet() {
|
||||
return "", ErrKeyNotSet
|
||||
}
|
||||
|
||||
|
||||
block, err := aes.NewCipher(masterSecretKey)
|
||||
if err != nil {
|
||||
return "", err
|
||||
|
||||
@@ -8,6 +8,7 @@ import (
|
||||
func GenerateID() string {
|
||||
return xid.New().String()
|
||||
}
|
||||
|
||||
// IsNumeric 检查字符串是否全为数字
|
||||
func IsNumeric(s string) bool {
|
||||
for _, c := range s {
|
||||
|
||||
@@ -12,7 +12,7 @@ func GetRepoIdentifier(url string, branch string) string {
|
||||
url = strings.TrimSuffix(url, "/")
|
||||
|
||||
repoName := url[strings.LastIndex(url, "/")+1:]
|
||||
|
||||
|
||||
author := ""
|
||||
lastSlash := strings.LastIndex(url, "/")
|
||||
if lastSlash != -1 {
|
||||
@@ -43,7 +43,7 @@ func GetRepoIdentifier(url string, branch string) string {
|
||||
if branch != "" && branch != "master" && branch != "main" {
|
||||
identifier = identifier + "_" + branch
|
||||
}
|
||||
|
||||
|
||||
// Replace any invalid characters for tags or paths
|
||||
identifier = strings.ReplaceAll(identifier, "/", "_")
|
||||
identifier = strings.ReplaceAll(identifier, ".", "_")
|
||||
|
||||
@@ -14,7 +14,6 @@ var (
|
||||
shellOnce sync.Once
|
||||
)
|
||||
|
||||
|
||||
// GetShell 返回当前操作系统的 shell 和参数
|
||||
func GetShell() (shell string, args []string) {
|
||||
shellOnce.Do(func() {
|
||||
|
||||
Reference in New Issue
Block a user