tags Clone() and CloneDeep()

This commit is contained in:
fiatjaf
2025-03-11 16:35:51 -03:00
parent 7df79c1845
commit 42a2243b72

23
tags.go
View File

@@ -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