fix: remove unused functions RegexpFindSubString, String2int, Utf8ToGbk and unused imports
This commit is contained in:
@@ -8,24 +8,19 @@ import (
|
||||
"crypto/rand"
|
||||
"crypto/sha256"
|
||||
"encoding/base64"
|
||||
"errors"
|
||||
"fmt"
|
||||
"image"
|
||||
"image/png"
|
||||
"io/ioutil"
|
||||
"net"
|
||||
"os"
|
||||
"path/filepath"
|
||||
"reflect"
|
||||
"regexp"
|
||||
"sort"
|
||||
"strconv"
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
"golang.org/x/crypto/ssh"
|
||||
"golang.org/x/text/encoding/simplifiedchinese"
|
||||
"golang.org/x/text/transform"
|
||||
|
||||
"github.com/google/uuid"
|
||||
"golang.org/x/crypto/pbkdf2"
|
||||
@@ -259,24 +254,6 @@ func DeCryptPassword(cryptPassword string, key []byte) (string, error) {
|
||||
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) {
|
||||
session, err := client.NewSession()
|
||||
if err != nil {
|
||||
@@ -316,15 +293,6 @@ func DirSize(path string) (int64, error) {
|
||||
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 {
|
||||
value, _ = strconv.ParseFloat(fmt.Sprintf("%.2f", value), 64)
|
||||
return value
|
||||
|
||||
Reference in New Issue
Block a user