mirror of
https://github.com/openimsdk/open-im-server.git
synced 2026-05-09 03:25:59 +08:00
api nil slice map
This commit is contained in:
@@ -529,3 +529,15 @@ func Batch[T any, V any](fn func(T) V, ts []T) []V {
|
||||
}
|
||||
return res
|
||||
}
|
||||
|
||||
func InitSlice[T any](val *[]T) {
|
||||
if val != nil && *val == nil {
|
||||
*val = []T{}
|
||||
}
|
||||
}
|
||||
|
||||
func InitMap[K comparable, V any](val *map[K]V) {
|
||||
if val != nil && *val == nil {
|
||||
*val = map[K]V{}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user