fix: remove unused functions RegexpFindSubString, String2int, Utf8ToGbk and unused imports

This commit is contained in:
2026-04-19 16:21:38 +08:00
parent b6aabfb7c4
commit f8890a5479
-32
View File
@@ -8,24 +8,19 @@ import (
"crypto/rand" "crypto/rand"
"crypto/sha256" "crypto/sha256"
"encoding/base64" "encoding/base64"
"errors"
"fmt" "fmt"
"image" "image"
"image/png" "image/png"
"io/ioutil"
"net" "net"
"os" "os"
"path/filepath" "path/filepath"
"reflect" "reflect"
"regexp"
"sort" "sort"
"strconv" "strconv"
"strings" "strings"
"time" "time"
"golang.org/x/crypto/ssh" "golang.org/x/crypto/ssh"
"golang.org/x/text/encoding/simplifiedchinese"
"golang.org/x/text/transform"
"github.com/google/uuid" "github.com/google/uuid"
"golang.org/x/crypto/pbkdf2" "golang.org/x/crypto/pbkdf2"
@@ -259,24 +254,6 @@ func DeCryptPassword(cryptPassword string, key []byte) (string, error) {
return string(decryptedCBC), nil return string(decryptedCBC), nil
} }
func RegexpFindSubString(text string, reg *regexp.Regexp) (ret string, err error) {
findErr := errors.New("regexp find failed")
res := reg.FindStringSubmatch(text)
if len(res) != 2 {
return "", findErr
}
return res[1], nil
}
func String2int(s string) (int, error) {
i, err := strconv.Atoi(s)
if err != nil {
return 0, err
}
return i, nil
}
func RunCommand(client *ssh.Client, command string) (stdout string, err error) { func RunCommand(client *ssh.Client, command string) (stdout string, err error) {
session, err := client.NewSession() session, err := client.NewSession()
if err != nil { if err != nil {
@@ -316,15 +293,6 @@ func DirSize(path string) (int64, error) {
return size, err return size, err
} }
func Utf8ToGbk(s []byte) ([]byte, error) {
reader := transform.NewReader(bytes.NewReader(s), simplifiedchinese.GBK.NewEncoder())
d, e := ioutil.ReadAll(reader)
if e != nil {
return nil, e
}
return d, nil
}
func Decimal(value float64) float64 { func Decimal(value float64) float64 {
value, _ = strconv.ParseFloat(fmt.Sprintf("%.2f", value), 64) value, _ = strconv.ParseFloat(fmt.Sprintf("%.2f", value), 64)
return value return value