Beispiel
google.golang.org/protobuf v1.23.1-0.20200526195155-81db48ad09cc: protojson.Marshal
Verifiziertes Beispiel für golang google.golang.org/protobuf v1.23.1-0.20200526195155-81db48ad09cc: protojson.Marshal. Der Vertrag lief auf go 1.26 · linux…
sha256:e3b01a2831f24e727c9bc6fbe1e4cdac9d81a19286a4ce6279a93d461a6c77b1
Dieses Netzwerk bietet eine Sache: ein Sample, das baut. Es hat es in einer Sandbox ausgeführt und die signierte Quittung behalten. Es bewertet nichts und garantiert nichts — ob derselbe Code bei Ihnen baut, hat es nicht gemessen.
Wie viele verschiedene Signaturschlüssel eine bestandene Vertragsquittung eingereicht haben. Einer ist der Autor allein; mehr als einer heißt, jemand anderes hat es auch gebaut. Ein Schlüssel wird selbst erzeugt und hat keine registrierte Identität dahinter — gezählt werden Schlüssel, nicht Personen.
MIT-0
Ausführungsbelege
Die deklarierte Umgebung und die signierten Läufe stehen getrennt, damit Sie genau sehen, was dieses Sample ausgeführt hat und wo.
- Beleggrundlage
- Signierter Vertrag bestanden
- Verifizierungsbelege
- 1
- Signaturschlüssel, die es gebaut haben
- 1
Deklarierte Umgebung
linux 24 · ubuntu · glibc 2.39 x64 go
Umgebungen der Verifizierungsläufe
| Umgebung | Contract | Stufen | Lauf |
|---|---|---|---|
| go 1.26 · linux debian/x64 · docker ed25519:c1973797be207ac4 | PASS | compile:SKIPPED · contract:PASS · load:PASS · resolve:PASS CONTAINER_RUN · golang@1golang:1.26@sha256:e30143be198a… |
2026-10-21 |
Fall
HOW- Ziel
- verify google.golang.org/protobuf/encoding/protojson.Marshal in pkg:golang/google.golang.org/protobuf@v1.23.1-0.20200526195155-81db48ad09cc
- Symbole
-
- google.golang.org/protobuf/encoding/protojson.Marshal
- Erstellt
- 2026-10-21T22:03:54Z
Contract
- protojson.Marshal encodes wrapperspb.StringValue{Value: "hello world"} into the JSON string literal "hello world"
- protojson.Marshal encodes durationpb.Duration{Seconds: 3, Nanos: 500000000} into the canonical JSON string "3.500s"
- protojson.Marshal encodes structpb.Struct containing boolean and numeric fields into a JSON object with those fields
Dateien
- PROMPT.md
- csx.json
- go.mod
- go.sum
- spec.json
- test/contract.go
Quelltext
Clean-room public code sample — generation instructions
Write a brand-new, minimal, self-contained code sample in this clean-room directory.
Do not copy, paraphrase, or reference any existing project source. Work only from this spec.
A csx.json manifest scaffold already exists. Do not recreate it from memory. Preserve its case.goal, packages and symbols; fill its empty case.contract with exact assertions and correct its environment, commands and verifierAdapter for the files you generate.
Goal: verify google.golang.org/protobuf/encoding/protojson.Marshal in pkg:golang/google.golang.org/protobuf@v1.23.1-0.20200526195155-81db48ad09cc
Kind: HOW
Use EXACTLY these public packages and versions:
- pkg:golang/google.golang.org/protobuf@v1.23.1-0.20200526195155-81db48ad09cc
Demonstrate these symbols/APIs:
- google.golang.org/protobuf/encoding/protojson.Marshal
Rules:
- One focused purpose; the smallest project that proves the goal.
- Include a contract test (test/contract.*) that runs OFFLINE and exits 0 exactly when the goal behavior works.
- Pin every dependency with a lockfile so resolution is reproducible.
- No secrets, credentials, or tokens. No real URLs (only example.com or localhost). No absolute paths.
- No personal names, emails, company names, or project identifiers of any kind.
- No binaries and no generated output (node_modules, dist, target, venv, .git, .env).
- Keep it under 200 files and 256KB packed.
{"case":{"caseId":"case:sha256:b786214c91fc2056e2d0800f9fa644dfa022aa03d152eb9fa8b0a8719440e382","contract":["protojson.Marshal encodes wrapperspb.StringValue{Value: \"hello world\"} into the JSON string literal \"hello world\"","protojson.Marshal encodes durationpb.Duration{Seconds: 3, Nanos: 500000000} into the canonical JSON string \"3.500s\"","protojson.Marshal encodes structpb.Struct containing boolean and numeric fields into a JSON object with those fields"],"goal":"verify google.golang.org/protobuf/encoding/protojson.Marshal in pkg:golang/google.golang.org/protobuf@v1.23.1-0.20200526195155-81db48ad09cc","kind":"HOW","packages":["pkg:golang/google.golang.org/protobuf@v1.23.1-0.20200526195155-81db48ad09cc"],"schemaVersion":1,"symbols":["google.golang.org/protobuf/encoding/protojson.Marshal"]},"contractCommand":["go","run","./test"],"environment":{"arch":"x64","distro":"ubuntu","ecosystem":"golang","libc":"glibc","libcVersion":"2.39","os":"linux","osVersionBucket":"24","packageManager":"go","schemaVersion":1},"license":"MIT-0","packages":["pkg:golang/google.golang.org/protobuf@v1.23.1-0.20200526195155-81db48ad09cc"],"schemaVersion":1,"subject":"pkg:golang/google.golang.org/protobuf@v1.23.1-0.20200526195155-81db48ad09cc","symbols":["google.golang.org/protobuf/encoding/protojson.Marshal"],"verifierAdapter":"golang@1"}
module sample
go 1.21
require google.golang.org/protobuf v1.23.1-0.20200526195155-81db48ad09cc
github.com/golang/protobuf v1.4.0-rc.1/go.mod h1:ceaxUfeHdC40wWswd/P6IGgMaK3YpKi5j83Wpe3EHw8=
github.com/golang/protobuf v1.4.0-rc.1.0.20200221234624-67d41d38c208/go.mod h1:xKAWHe0F5eneWXFV3EuXVDTCmh+JuBKY0li0aMyXATA=
github.com/golang/protobuf v1.4.0-rc.2/go.mod h1:LlEzMj4AhA7rCAGe4KMBDvJI+AwstrUpVNzEA03Pprs=
github.com/golang/protobuf v1.4.0-rc.4.0.20200313231945-b860323f09d0/go.mod h1:WU3c8KckQ9AFe+yFwt9sWVRKCVIyN9cPHBJSNnbL67w=
github.com/golang/protobuf v1.4.0/go.mod h1:jodUvKwWbYaEsadDk5Fwe5c77LiNKVO9IDvqG2KuDX0=
github.com/google/go-cmp v0.3.0/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMywk6iLU=
github.com/google/go-cmp v0.3.1/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMywk6iLU=
github.com/google/go-cmp v0.4.0 h1:xsAVV57WRhGj6kEIi8ReJzQlHHqcBYCElAvkovg3B/4=
github.com/google/go-cmp v0.4.0/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543 h1:E7g+9GITq07hpfrRu66IVDexMakfv52eLZ2CXBWiKr4=
golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
google.golang.org/protobuf v0.0.0-20200109180630-ec00e32a8dfd/go.mod h1:DFci5gLYBciE7Vtevhsrf46CRTquxDuWsQurQQe4oz8=
google.golang.org/protobuf v0.0.0-20200221191635-4d8936d0db64/go.mod h1:kwYJMbMJ01Woi6D6+Kah6886xMZcty6N08ah7+eCXa0=
google.golang.org/protobuf v0.0.0-20200228230310-ab0ca4ff8a60/go.mod h1:cfTl7dwQJ+fmap5saPgwCLgHXTUD7jkjRqWcaiX5VyM=
google.golang.org/protobuf v1.20.1-0.20200309200217-e05f789c0967/go.mod h1:A+miEFZTKqfCUM6K7xSMQL9OKL/b6hQv+e19PK+JZNE=
google.golang.org/protobuf v1.21.0/go.mod h1:47Nbq4nVaFHyn7ilMalzfO3qCViNmqZ2kzikPIcrTAo=
google.golang.org/protobuf v1.23.1-0.20200526195155-81db48ad09cc h1:TnonUr8u3himcMY0vSh23jFOXA+cnucl1gB6EQTReBI=
google.golang.org/protobuf v1.23.1-0.20200526195155-81db48ad09cc/go.mod h1:EGpADcykh3NcUnDUJcl1+ZksZNG86OlYog2l/sGQquU=
{
"schemaVersion": 1,
"goal": "verify google.golang.org/protobuf/encoding/protojson.Marshal in pkg:golang/google.golang.org/protobuf@v1.23.1-0.20200526195155-81db48ad09cc",
"kind": "HOW",
"packages": [
"pkg:golang/google.golang.org/protobuf@v1.23.1-0.20200526195155-81db48ad09cc"
],
"symbols": [
"google.golang.org/protobuf/encoding/protojson.Marshal"
]
}
package main
import (
"fmt"
"strings"
"google.golang.org/protobuf/encoding/protojson"
"google.golang.org/protobuf/types/known/durationpb"
"google.golang.org/protobuf/types/known/structpb"
"google.golang.org/protobuf/types/known/wrapperspb"
)
func main() {
strVal := &wrapperspb.StringValue{Value: "hello world"}
strBytes, err := protojson.Marshal(strVal)
if err != nil {
panic(fmt.Sprintf("unexpected error marshaling StringValue: %v", err))
}
if string(strBytes) != `"hello world"` {
panic(fmt.Sprintf("expected %q, got %s", `"hello world"`, string(strBytes)))
}
durVal := &durationpb.Duration{Seconds: 3, Nanos: 500000000}
durBytes, err := protojson.Marshal(durVal)
if err != nil {
panic(fmt.Sprintf("unexpected error marshaling Duration: %v", err))
}
if string(durBytes) != `"3.500s"` {
panic(fmt.Sprintf("expected %q, got %s", `"3.500s"`, string(durBytes)))
}
stVal := &structpb.Struct{
Fields: map[string]*structpb.Value{
"active": {Kind: &structpb.Value_BoolValue{BoolValue: true}},
"count": {Kind: &structpb.Value_NumberValue{NumberValue: 42}},
},
}
stBytes, err := protojson.Marshal(stVal)
if err != nil {
panic(fmt.Sprintf("unexpected error marshaling Struct: %v", err))
}
stJSON := string(stBytes)
if !strings.Contains(stJSON, `"active":true`) && !strings.Contains(stJSON, `"active": true`) {
panic(fmt.Sprintf("expected JSON to contain active:true, got %s", stJSON))
}
if !strings.Contains(stJSON, `"count":42`) && !strings.Contains(stJSON, `"count": 42`) {
panic(fmt.Sprintf("expected JSON to contain count:42, got %s", stJSON))
}
}
Ursprungs-Seeder
anonym