feat: 可通过 slice.Merge 合并多个切片数据

This commit is contained in:
kercylan98 2023-07-05 21:30:23 +08:00
parent 6634aa675e
commit ebfdd7c281
1 changed files with 9 additions and 0 deletions

View File

@ -120,3 +120,12 @@ func ToSet[V comparable](slice []V) map[V]struct{} {
} }
return m return m
} }
// Merge 合并多个数组
func Merge[V any](slices ...[]V) []V {
var slice []V
for _, s := range slices {
slice = append(slice, s...)
}
return slice
}