From 42a2243b726fd83b96361e8e0591eea864e303c7 Mon Sep 17 00:00:00 2001 From: fiatjaf Date: Tue, 11 Mar 2025 16:35:51 -0300 Subject: [PATCH] tags Clone() and CloneDeep() --- tags.go | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/tags.go b/tags.go index ac15949..0e11297 100644 --- a/tags.go +++ b/tags.go @@ -201,6 +201,29 @@ func (tags Tags) FindLastWithValue(key, value string) Tag { return nil } +// Clone creates a new array with these tags inside. +func (tags Tags) Clone() Tag { + newArr := make(Tags, len(tags)) + copy(newArr, tags) + return nil +} + +// CloneDeep creates a new array with clones of these tags inside. +func (tags Tags) CloneDeep() Tag { + newArr := make(Tags, len(tags)) + for i := range newArr { + newArr[i] = tags[i].Clone() + } + return nil +} + +// Clone creates a new array with these tag items inside. +func (tag Tag) Clone() Tag { + newArr := make(Tag, len(tag)) + copy(newArr, tag) + return nil +} + // this exists to satisfy Postgres and stuff and should probably be removed in the future since it's too specific func (t *Tags) Scan(src any) error { var jtags []byte