1
0
mirror of https://github.com/go-task/task.git synced 2024-12-14 10:52:43 +02:00
task/taskfile/copy.go

24 lines
376 B
Go
Raw Normal View History

2022-10-02 07:45:27 +02:00
package taskfile
import "golang.org/x/exp/constraints"
func deepCopySlice[T any](orig []T) []T {
if orig == nil {
return nil
}
c := make([]T, len(orig))
copy(c, orig)
return c
}
func deepCopyMap[K constraints.Ordered, V any](orig map[K]V) map[K]V {
if orig == nil {
return nil
}
c := make(map[K]V, len(orig))
for k, v := range orig {
c[k] = v
}
return c
}