add option metadata

This commit is contained in:
Денис Евстигнеев 2024-02-28 15:06:29 +03:00
parent 96dd5d869a
commit d667bbee0c

View File

@ -157,6 +157,22 @@ func Metadata(md metadata.Metadata) Option {
} }
} }
func MetadataAny(md any) Option {
result := metadata.Metadata{}
switch vt := md.(type) {
case metadata.Metadata:
result = metadata.Copy(vt)
case []string:
for index := 0; index < len(vt); index += 2 {
result[vt[index]] = result[vt[index]]
}
}
return func(src interface{}) error {
return Set(src, result, ".Metadata")
}
}
// Namespace to use // Namespace to use
func Namespace(ns string) Option { func Namespace(ns string) Option {
return func(src interface{}) error { return func(src interface{}) error {