aboutsummaryrefslogtreecommitdiffhomepage
path: root/common/collections/append.go
diff options
context:
space:
mode:
Diffstat (limited to 'common/collections/append.go')
-rw-r--r--common/collections/append.go7
1 files changed, 7 insertions, 0 deletions
diff --git a/common/collections/append.go b/common/collections/append.go
index fe8792fc4..91abc46d3 100644
--- a/common/collections/append.go
+++ b/common/collections/append.go
@@ -31,6 +31,13 @@ func Append(to any, from ...any) (any, error) {
var tot reflect.Type
if !toIsNil {
+ if tov.Kind() == reflect.Slice {
+ // Create a copy of tov, so we don't modify the original.
+ c := reflect.MakeSlice(tov.Type(), tov.Len(), tov.Len()+len(from))
+ reflect.Copy(c, tov)
+ tov = c
+ }
+
if tov.Kind() != reflect.Slice {
return nil, fmt.Errorf("expected a slice, got %T", to)
}