提交 v1.3.0 beta

This commit is contained in:
dushixiang
2022-10-23 20:05:13 +08:00
parent 4ff4d37442
commit 112435199a
329 changed files with 18340 additions and 58458 deletions

View File

@ -27,18 +27,18 @@ import (
"golang.org/x/text/encoding/simplifiedchinese"
"golang.org/x/text/transform"
"github.com/gofrs/uuid"
"github.com/google/uuid"
errors2 "github.com/pkg/errors"
"github.com/sirupsen/logrus"
"golang.org/x/crypto/pbkdf2"
)
func UUID() string {
v4, _ := uuid.NewV4()
return v4.String()
return uuid.New().String()
}
func LongUUID() string {
uuid.New()
longUUID := strings.Join([]string{UUID(), UUID(), UUID(), UUID()}, "")
return strings.ReplaceAll(longUUID, "-", "")
}
@ -56,7 +56,7 @@ func Tcping(ip string, port int) (bool, error) {
} else {
address = fmt.Sprintf("[%s]:%s", ip, strPort)
}
if conn, err = net.DialTimeout("tcp", address, 5*time.Second); err != nil {
if conn, err = net.DialTimeout("tcp", address, 15*time.Second); err != nil {
return false, err
}
defer func() {
@ -346,6 +346,11 @@ func Utf8ToGbk(s []byte) ([]byte, error) {
return d, nil
}
func Decimal(value float64) float64 {
value, _ = strconv.ParseFloat(fmt.Sprintf("%.2f", value), 64)
return value
}
// GetAvailablePort 获取可用端口
func GetAvailablePort() (int, error) {
addr, err := net.ResolveTCPAddr("tcp", "localhost:0")