Appending to metadata is a side effect. Let's not do that anymore.

This commit is contained in:
Asim
2016-04-15 16:45:59 +01:00
parent 0410508385
commit 089c457d6c
3 changed files with 71 additions and 10 deletions

View File

@@ -17,12 +17,5 @@ func FromContext(ctx context.Context) (Metadata, bool) {
}
func NewContext(ctx context.Context, md Metadata) context.Context {
if emd, ok := ctx.Value(metaKey{}).(Metadata); ok {
for k, v := range emd {
if _, ok := md[k]; !ok {
md[k] = v
}
}
}
return context.WithValue(ctx, metaKey{}, md)
}