metadata: sync with grpc
Some checks failed
coverage / build (push) Failing after 41s
test / test (push) Successful in 2m31s
sync / sync (push) Successful in 46s

Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
This commit is contained in:
2025-04-29 23:13:57 +03:00
parent 7ff7a3dbe0
commit e4ee705eb2
2 changed files with 11 additions and 25 deletions

View File

@@ -112,7 +112,7 @@ func (md Metadata) Get(k string) []string {
v, ok = md[strings.ToLower(k)]
}
if !ok {
v, ok = md[textproto.CanonicalMIMEHeaderKey(k)]
v = md[textproto.CanonicalMIMEHeaderKey(k)]
}
return v
}
@@ -124,24 +124,13 @@ func (md Metadata) GetJoined(k string) string {
}
// Set sets the value of a given key with a slice of values.
func (md Metadata) Add(key string, vals ...string) {
func (md Metadata) Set(key string, vals ...string) {
if len(vals) == 0 {
return
}
md[key] = vals
}
// Set sets the value of a given key with a slice of values.
func (md Metadata) Set(kvs ...string) {
if len(kvs)%2 == 1 {
panic(fmt.Sprintf("metadata: Set got an odd number of input pairs for metadata: %d", len(kvs)))
}
for i := 0; i < len(kvs); i += 2 {
md[kvs[i]] = append(md[kvs[i]], kvs[i+1])
}
}
// Append adds the values to key k, not overwriting what was already stored at
// that key.
func (md Metadata) Append(key string, vals ...string) {