fix: remove unused functions Check, InsertSlice, GetLocalIp
This commit is contained in:
@@ -29,7 +29,6 @@ import (
|
|||||||
|
|
||||||
"github.com/google/uuid"
|
"github.com/google/uuid"
|
||||||
errors2 "github.com/pkg/errors"
|
errors2 "github.com/pkg/errors"
|
||||||
"github.com/sirupsen/logrus"
|
|
||||||
"golang.org/x/crypto/pbkdf2"
|
"golang.org/x/crypto/pbkdf2"
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -196,12 +195,6 @@ func StringToInt(in string) (out int) {
|
|||||||
return
|
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) {
|
func ParseNetReg(line string, reg *regexp.Regexp, shouldLen, index int) (int64, string, error) {
|
||||||
rx1 := reg.FindStringSubmatch(line)
|
rx1 := reg.FindStringSubmatch(line)
|
||||||
if len(rx1) != shouldLen {
|
if len(rx1) != shouldLen {
|
||||||
@@ -368,29 +361,3 @@ func GetAvailablePort() (int, error) {
|
|||||||
}(l)
|
}(l)
|
||||||
return l.Addr().(*net.TCPAddr).Port, nil
|
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地址失败")
|
|
||||||
}
|
|
||||||
|
|||||||
Reference in New Issue
Block a user