fixup
Some checks failed
pr / test (pull_request) Failing after 2m16s
lint / lint (pull_request) Successful in 10m36s

Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
This commit is contained in:
Василий Толстов 2024-02-29 01:26:09 +03:00
parent 9dd64b1d81
commit 4fa0b2c82c

View File

@ -152,27 +152,24 @@ func ContentType(ct string) Option {
// Metadata pass additional metadata
func Metadata(md ...any) Option {
result := metadata.Metadata{}
if len(md) > 1 {
var tmp []string
for _, val := range md {
switch vt := val.(type) {
case string:
tmp = append(tmp, vt)
default:
return func(src interface{}) error {
return Set(src, result, ".Metadata")
}
}
}
result.Set(tmp...)
} else if len(md) == 1 {
var result metadata.Metadata
if len(md) == 1 {
switch vt := md[0].(type) {
case metadata.Metadata:
result = metadata.Copy(vt)
case map[string]string:
result = metadata.Copy(vt)
default:
result = metadata.New(0)
}
} else {
result = metadata.New(len(md) / 2)
for idx := 0; idx < len(md)/2; idx += 2 {
k, kok := md[idx].(string)
v, vok := md[idx+1].(string)
if kok && vok {
result.Set(k, v)
}
}
}