mirror of
https://github.com/go-task/task.git
synced 2024-12-14 10:52:43 +02:00
5e9851f42f
* feat: update minimum version to 1.22 * refactor: use int range iterator * refactor: loop variables * refactor: replace slicesext.FirstNonZero with cmp.Or * refactor: use slices.Concat instead of append * fix: unused param * fix: linting
21 lines
286 B
Go
21 lines
286 B
Go
package slicesext
|
|
|
|
import (
|
|
"cmp"
|
|
"slices"
|
|
)
|
|
|
|
func UniqueJoin[T cmp.Ordered](ss ...[]T) []T {
|
|
var length int
|
|
for _, s := range ss {
|
|
length += len(s)
|
|
}
|
|
r := make([]T, length)
|
|
var i int
|
|
for _, s := range ss {
|
|
i += copy(r[i:], s)
|
|
}
|
|
slices.Sort(r)
|
|
return slices.Compact(r)
|
|
}
|