context.go 299 B

1234567891011121314
  1. package context
  2. import (
  3. "context"
  4. "fmt"
  5. "google.golang.org/grpc/metadata"
  6. )
  7. func AppendToContext(ctx context.Context, key string, value interface{}) context.Context {
  8. ctx = context.WithValue(ctx, key, value)
  9. ctx = metadata.AppendToOutgoingContext(ctx, key, fmt.Sprint(value))
  10. return ctx
  11. }