groupServer

This commit is contained in:
withchao
2023-05-18 18:13:58 +08:00
parent 405a9b75b0
commit 711c4878a8
4 changed files with 148 additions and 35 deletions
+11
View File
@@ -509,3 +509,14 @@ func NotNilReplace[T any](old, new_ *T) {
}
*old = *new_
}
func Batch[T any, V any](fn func(T) V, ts []T) []V {
if ts == nil {
return nil
}
res := make([]V, 0, len(ts))
for i := range ts {
res = append(res, fn(ts[i]))
}
return res
}