feat(app): update
This commit is contained in:
@ -13,7 +13,7 @@ func NewStringBuilder() *StringBuilder {
|
||||
return &StringBuilder{buf: bytes.Buffer{}}
|
||||
}
|
||||
|
||||
func (this *StringBuilder) Append(obj interface{}) *StringBuilder {
|
||||
func (this *StringBuilder) Append(obj any) *StringBuilder {
|
||||
this.buf.WriteString(fmt.Sprintf("%v", obj))
|
||||
return this
|
||||
}
|
||||
|
||||
@ -270,13 +270,13 @@ func ByteSplit(buf []byte, lim int) [][]byte {
|
||||
}
|
||||
|
||||
// 强类型数组转为interface类型的数组
|
||||
func ToSlice(arr interface{}) []interface{} {
|
||||
func ToSlice(arr any) []any {
|
||||
v := reflect.ValueOf(arr)
|
||||
if v.Kind() != reflect.Slice {
|
||||
panic("toslice arr not slice")
|
||||
}
|
||||
l := v.Len()
|
||||
ret := make([]interface{}, l)
|
||||
ret := make([]any, l)
|
||||
for i := 0; i < l; i++ {
|
||||
ret[i] = v.Index(i).Interface()
|
||||
}
|
||||
@ -284,10 +284,10 @@ func ToSlice(arr interface{}) []interface{} {
|
||||
}
|
||||
|
||||
// 从字符串数组随机获取一个数组
|
||||
func GetRandArrayFromArray(sourceArr []interface{}, resultCount int) (resultArr []interface{}) {
|
||||
func GetRandArrayFromArray(sourceArr []any, resultCount int) (resultArr []any) {
|
||||
|
||||
// 结果
|
||||
resultArr = make([]interface{}, 0)
|
||||
resultArr = make([]any, 0)
|
||||
|
||||
if len(sourceArr) < resultCount {
|
||||
return
|
||||
@ -329,7 +329,7 @@ func IPToUint32(ip string) (uint32, error) {
|
||||
return uint32(num), nil
|
||||
}
|
||||
|
||||
func JsonStr(v interface{}) string {
|
||||
func JsonStr(v any) string {
|
||||
b, _ := json.Marshal(v)
|
||||
return string(b)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user