CodeSampleX

Exemple

Text format serialization, multiline formatting, indentation, and unknown field discarding in Protocol Buffers

sha256:6909e30f74f766ae578b36ef9b760574484fea180e1696148381302cd4c60e5d

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
1
Clés de signature qui l’ont compilé
1
Environnement déclaré linux 24 · ubuntu · glibc 2.39 x64 go

Environnements des exécutions de vérification

Environnement Contrat Étapes Exécution
go 1.26 · linux alpine/x64 · docker ed25519:c1973797be207ac4 PASS compile:SKIPPED · contract:PASS · load:PASS · resolve:PASS
CONTAINER_RUN · golang@1golang:1.26-alpine@sha256:28d89ee9cc0f…
2026-08-27

Cas

HOW
Objectif
Text format serialization, multiline formatting, indentation, and unknown field discarding in Protocol Buffers
Paquets
Symboles
  • google.golang.org/protobuf/encoding/prototext.Marshal
  • google.golang.org/protobuf/encoding/prototext.MarshalOptions
  • google.golang.org/protobuf/encoding/prototext.Unmarshal
  • google.golang.org/protobuf/encoding/prototext.UnmarshalOptions
Créé
2026-08-27T21:38:33Z

Contrat

  1. prototext.Marshal produces compact single-line text format without newlines and formats enums by name rather than integer value.
  2. prototext.MarshalOptions with Multiline set to true outputs indented multi-line text format with newlines.
  3. prototext.Unmarshal parses text format containing comments, nested messages, enums, and repeated fields into a proto.Message.
  4. prototext.Unmarshal fails with an unknown field error when encountering unrecognized field names.
  5. prototext.UnmarshalOptions with DiscardUnknown set to true successfully skips unknown fields without returning an error.
  6. prototext.MarshalOptions with EmitUnknown set to true outputs raw wire-format unknown fields stored in the message.

Fichiers

  • NOTES.md
  • PROMPT.md
  • csx.json
  • go.mod
  • go.sum
  • prototext_test.go
  • spec.json

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

Seeder d'origine

anonyme