CodeSampleX

Exemple

google.golang.org/grpc v1.83.0: Preserve caller-supplied outgoing gRPC metadata when a unary client interceptor adds its own metadata

Échantillon vérifié pour golang google.golang.org/grpc v1.83.0: Preserve caller-supplied outgoing gRPC metadata when a unary client interceptor adds its own…

sha256:a8acd8ef9a84180020f012467fae967f3de130dff4d432708ac5bf0a6df64717

Ce réseau offre une seule chose : un échantillon qui compile. Il l'a exécuté dans un bac à sable et conservé le reçu signé. Il ne note rien et ne garantit rien : si le même code compile chez vous, il ne l'a pas mesuré. Combien de clés de signature distinctes ont déposé un reçu de contrat réussi. Une seule, c'est l'auteur ; plus d'une signifie que quelqu'un d'autre l'a compilé aussi. Une clé est auto-générée sans identité enregistrée derrière, donc on compte des clés, pas des personnes. MIT-0

Preuves d'exécution

L'environnement déclaré et les exécutions signées sont séparés, pour que vous voyiez exactement ce que cet échantillon a exécuté et où.

Base de preuve
Contrat signé réussi
Reçus de vérification
2
Clés de signature qui l’ont compilé
2
Environnement déclaré go 1.26 linux x64 go 1.26 go go

Environnements des exécutions de vérification

Environnement Contrat Étapes Exécution
go 1.26 · linux alpine/x64 · docker ed25519:d91480838ac982c9 PASS compile:SKIPPED · contract:PASS · load:PASS · resolve:PASS
CONTAINER_RUN · golang@1
2026-08-17
go 1.26 · linux alpine/x64 · docker ed25519:2175b912ea1c23b1 PASS compile:SKIPPED · contract:PASS · load:PASS · resolve:PASS
CONTAINER_RUN · golang@1
2026-08-18

Cas

HOW
Objectif
Preserve caller-supplied outgoing gRPC metadata when a unary client interceptor adds its own metadata
Paquets
Symboles
  • google.golang.org/grpc.NewServer
  • google.golang.org/grpc.Server.RegisterService
  • google.golang.org/grpc.NewClient
  • google.golang.org/grpc.WithContextDialer
  • google.golang.org/grpc.WithTransportCredentials
  • google.golang.org/grpc.WithUnaryInterceptor
  • google.golang.org/grpc.ClientConn.Invoke
  • google.golang.org/grpc/test/bufconn.Listen
  • google.golang.org/grpc/metadata.NewOutgoingContext
  • google.golang.org/grpc/metadata.AppendToOutgoingContext
  • google.golang.org/grpc/metadata.FromIncomingContext
  • google.golang.org/grpc/status.Code
Environnement
go 1.26
Créé
2026-08-17T01:31:28Z

Contrat

  1. A grpc.NewClient call reaches a manually registered unary service through bufconn, a context dialer, and insecure transport credentials without opening a TCP listener.
  2. When a unary client interceptor uses metadata.NewOutgoingContext, the server receives the interceptor field but not the caller's existing x-caller field, and its status error arrives at the client as codes.Unauthenticated.
  3. When the interceptor uses metadata.AppendToOutgoingContext instead, metadata.FromIncomingContext sees both the caller and interceptor fields and the unary call succeeds.

Fichiers

  • NOTES.md
  • csx.json
  • go.mod
  • go.sum
  • metadata_interceptor_test.go

Télécharger l’artefact source (tar.gz)

Seeder d'origine

csx-seed