31 lines
478 B
Go
31 lines
478 B
Go
// Copyright (c) 2024-2026 Celestino Amoroso (celestino.amoroso@gmail.com).
|
|
// All rights reserved.
|
|
|
|
// clone-value.go
|
|
package kern
|
|
|
|
func Clone(v any) (c any) {
|
|
if v == nil {
|
|
return
|
|
}
|
|
switch unboxed := v.(type) {
|
|
case int64:
|
|
c = unboxed
|
|
case float64:
|
|
c = unboxed
|
|
case string:
|
|
c = unboxed
|
|
case bool:
|
|
c = unboxed
|
|
case *ListType:
|
|
c = unboxed.Clone()
|
|
case *DictType:
|
|
c = unboxed.Clone()
|
|
case *LinkedList:
|
|
c = unboxed.Clone()
|
|
default:
|
|
c = v
|
|
}
|
|
return
|
|
}
|