fix: remove unused functions Check, InsertSlice, GetLocalIp

This commit is contained in:
2026-04-19 09:31:10 +08:00
parent c543cd3db5
commit 5da60cb239
-33
View File
@@ -29,7 +29,6 @@ import (
"github.com/google/uuid"
errors2 "github.com/pkg/errors"
"github.com/sirupsen/logrus"
"golang.org/x/crypto/pbkdf2"
)
@@ -196,12 +195,6 @@ func StringToInt(in string) (out int) {
return
}
func Check(f func() error) {
if err := f(); err != nil {
logrus.Error("Received error:", err)
}
}
func ParseNetReg(line string, reg *regexp.Regexp, shouldLen, index int) (int64, string, error) {
rx1 := reg.FindStringSubmatch(line)
if len(rx1) != shouldLen {
@@ -368,29 +361,3 @@ func GetAvailablePort() (int, error) {
}(l)
return l.Addr().(*net.TCPAddr).Port, nil
}
func InsertSlice(index int, new []rune, src []rune) (ns []rune) {
ns = append(ns, src[:index]...)
ns = append(ns, new...)
ns = append(ns, src[index:]...)
return ns
}
func GetLocalIp() (string, error) {
addrs, err := net.InterfaceAddrs()
if err != nil {
return "", err
}
for _, address := range addrs {
// 检查ip地址判断是否回环地址
if ipNet, ok := address.(*net.IPNet); ok && !ipNet.IP.IsLoopback() {
if ipNet.IP.To4() != nil {
return ipNet.IP.String(), nil
}
}
}
return "", errors.New("获取本机IP地址失败")
}