metadata: allow to exclude some keys in Copy func (#321)

Reviewed-on: #321
Co-authored-by: Vasiliy Tolstov <v.tolstov@unistack.org>
Co-committed-by: Vasiliy Tolstov <v.tolstov@unistack.org>
This commit was merged in pull request #321.
This commit is contained in:
2024-03-09 23:50:40 +03:00
parent ed7972a1fa
commit f66ac9736b
2 changed files with 13 additions and 1 deletions

View File

@@ -98,11 +98,12 @@ func (md Metadata) Del(keys ...string) {
}
// Copy makes a copy of the metadata
func Copy(md Metadata) Metadata {
func Copy(md Metadata, exclude ...string) Metadata {
nmd := New(len(md))
for key, val := range md {
nmd.Set(key, val)
}
nmd.Del(exclude...)
return nmd
}