Beispiel
google.golang.org/genproto/googleapis/rpc v0.0.0-20241007155032-5fefd90f89a9: errdetails.RetryInfo
Verifiziertes Beispiel für golang google.golang.org/genproto/googleapis/rpc v0.0.0-20241007155032-5fefd90f89a9: errdetails.RetryInfo. Der Vertrag lief auf go…
sha256:d43d71899d406ff6170b741f3ccd4cb3ff0b900221e87667c30a1e0d34b0d25b
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 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 |
Fall
HOW- Ziel
- verify google.golang.org/genproto/googleapis/rpc/errdetails.RetryInfo in pkg:golang/google.golang.org/genproto/googleapis/rpc@v0.0.0-20241007155032-5fefd90f89a9
- Symbole
-
- google.golang.org/genproto/googleapis/rpc/errdetails.RetryInfo
- Erstellt
- 2026-08-27T11:57:22Z
Contract
- RetryInfo initializes with durationpb RetryDelay and retrieves duration accurately
- RetryInfo packs into anypb.Any and unpacks back successfully
- RetryInfo integrates into status.Status details and roundtrips through proto serialization
- RetryInfo handles nil RetryDelay safely returning nil
- RetryInfo message matches anypb.MessageIs type check
Dateien
- PROMPT.md
- csx.json
- go.mod
- go.sum
- main.go
- 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/genproto/googleapis/rpc/errdetails.RetryInfo in pkg:golang/google.golang.org/genproto/googleapis/rpc@v0.0.0-20241007155032-5fefd90f89a9
Kind: HOW
Use EXACTLY these public packages and versions:
- pkg:golang/google.golang.org/genproto/googleapis/rpc@v0.0.0-20241007155032-5fefd90f89a9
Demonstrate these symbols/APIs:
- google.golang.org/genproto/googleapis/rpc/errdetails.RetryInfo
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:8e2350702b52e0b6768d46e683a56bd82424abb19c113991a3a0cf6af0b4f4ab","contract":["RetryInfo initializes with durationpb RetryDelay and retrieves duration accurately","RetryInfo packs into anypb.Any and unpacks back successfully","RetryInfo integrates into status.Status details and roundtrips through proto serialization","RetryInfo handles nil RetryDelay safely returning nil","RetryInfo message matches anypb.MessageIs type check"],"goal":"verify google.golang.org/genproto/googleapis/rpc/errdetails.RetryInfo in pkg:golang/google.golang.org/genproto/googleapis/rpc@v0.0.0-20241007155032-5fefd90f89a9","kind":"HOW","packages":["pkg:golang/google.golang.org/genproto/googleapis/rpc@v0.0.0-20241007155032-5fefd90f89a9"],"schemaVersion":1,"symbols":["google.golang.org/genproto/googleapis/rpc/errdetails.RetryInfo"]},"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/genproto/googleapis/rpc@v0.0.0-20241007155032-5fefd90f89a9"],"schemaVersion":1,"subject":"pkg:golang/google.golang.org/genproto/googleapis/rpc@v0.0.0-20241007155032-5fefd90f89a9","symbols":["google.golang.org/genproto/googleapis/rpc/errdetails.RetryInfo"],"verifierAdapter":"golang@1"}
module example.com/sample
go 1.22
require (
google.golang.org/genproto/googleapis/rpc v0.0.0-20241007155032-5fefd90f89a9
google.golang.org/protobuf v1.35.1
)
github.com/google/go-cmp v0.5.9 h1:O2Tfq5qg4qc4AmwVlvv0oLiVAGB7enBSJ2x2DqQFi38=
github.com/google/go-cmp v0.5.9/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY=
google.golang.org/genproto/googleapis/rpc v0.0.0-20241007155032-5fefd90f89a9 h1:QCqS/PdaHTSWGvupk2F/ehwHtGc0/GYkT+3GAcR1CCc=
google.golang.org/genproto/googleapis/rpc v0.0.0-20241007155032-5fefd90f89a9/go.mod h1:GX3210XPVPUjJbTUbvwI8f2IpZDMZuPJWDzDuebbviI=
google.golang.org/protobuf v1.35.1 h1:m3LfL6/Ca+fqnjnlqQXNpFPABW1UD7mjh8KO2mKFytA=
google.golang.org/protobuf v1.35.1/go.mod h1:9fA7Ob0pmnwhb644+1+CVWFRbNajQ6iRojtC/QF5bRE=
package main
import (
"fmt"
"log"
"time"
"google.golang.org/genproto/googleapis/rpc/code"
"google.golang.org/genproto/googleapis/rpc/errdetails"
"google.golang.org/genproto/googleapis/rpc/status"
"google.golang.org/protobuf/proto"
"google.golang.org/protobuf/types/known/anypb"
"google.golang.org/protobuf/types/known/durationpb"
)
func main() {
// 1. Create a RetryInfo detail indicating a retry backoff duration
retryInfo := &errdetails.RetryInfo{
RetryDelay: durationpb.New(15 * time.Second),
}
// 2. Pack RetryInfo into Any protobuf message
anyRetryInfo, err := anypb.New(retryInfo)
if err != nil {
log.Fatalf("failed to pack retry info: %v", err)
}
// 3. Attach RetryInfo Any message into standard RPC status
rpcStatus := &status.Status{
Code: int32(code.Code_UNAVAILABLE),
Message: "service temporarily unavailable, please retry later",
Details: []*anypb.Any{anyRetryInfo},
}
// 4. Serialize Status to binary protobuf
data, err := proto.Marshal(rpcStatus)
if err != nil {
log.Fatalf("failed to marshal status: %v", err)
}
// 5. Unmarshal and unpack RetryInfo
var decoded status.Status
if err := proto.Unmarshal(data, &decoded); err != nil {
log.Fatalf("failed to unmarshal status: %v", err)
}
for _, detail := range decoded.GetDetails() {
if detail.MessageIs(&errdetails.RetryInfo{}) {
unpacked := &errdetails.RetryInfo{}
if err := detail.UnmarshalTo(unpacked); err != nil {
log.Fatalf("failed to unpack detail: %v", err)
}
fmt.Printf("Retry delay: %v\n", unpacked.GetRetryDelay().AsDuration())
}
}
}
{
"schemaVersion": 1,
"goal": "verify google.golang.org/genproto/googleapis/rpc/errdetails.RetryInfo in pkg:golang/google.golang.org/genproto/googleapis/rpc@v0.0.0-20241007155032-5fefd90f89a9",
"kind": "HOW",
"packages": [
"pkg:golang/google.golang.org/genproto/googleapis/rpc@v0.0.0-20241007155032-5fefd90f89a9"
],
"symbols": [
"google.golang.org/genproto/googleapis/rpc/errdetails.RetryInfo"
]
}
package main
import (
"fmt"
"os"
"time"
"google.golang.org/genproto/googleapis/rpc/code"
"google.golang.org/genproto/googleapis/rpc/errdetails"
"google.golang.org/genproto/googleapis/rpc/status"
"google.golang.org/protobuf/proto"
"google.golang.org/protobuf/types/known/anypb"
"google.golang.org/protobuf/types/known/durationpb"
)
func assert(condition bool, message string) {
if !condition {
fmt.Fprintf(os.Stderr, "Assertion failed: %s\n", message)
os.Exit(1)
}
}
func main() {
// 1. RetryInfo initializes with durationpb RetryDelay and retrieves duration accurately
expectedDuration := 10 * time.Second
retryInfo := &errdetails.RetryInfo{
RetryDelay: durationpb.New(expectedDuration),
}
assert(retryInfo.GetRetryDelay() != nil, "RetryDelay should not be nil")
assert(retryInfo.GetRetryDelay().GetSeconds() == 10, "RetryDelay seconds should be 10")
assert(retryInfo.GetRetryDelay().GetNanos() == 0, "RetryDelay nanos should be 0")
assert(retryInfo.GetRetryDelay().AsDuration() == expectedDuration, "RetryDelay AsDuration should match expectedDuration")
// 2. RetryInfo packs into anypb.Any and unpacks back successfully
anyMsg, err := anypb.New(retryInfo)
assert(err == nil, "anypb.New(retryInfo) should succeed")
assert(anyMsg != nil, "anyMsg should not be nil")
unpacked := &errdetails.RetryInfo{}
err = anypb.UnmarshalTo(anyMsg, unpacked, proto.UnmarshalOptions{})
assert(err == nil, "UnmarshalTo should succeed")
assert(unpacked.GetRetryDelay().AsDuration() == expectedDuration, "unpacked retry duration should match")
// 3. RetryInfo integrates into status.Status details and roundtrips through proto serialization
rpcStatus := &status.Status{
Code: int32(code.Code_UNAVAILABLE),
Message: "service overloaded, please back off",
Details: []*anypb.Any{anyMsg},
}
data, err := proto.Marshal(rpcStatus)
assert(err == nil, "proto.Marshal should succeed")
assert(len(data) > 0, "marshaled bytes should not be empty")
var decodedStatus status.Status
err = proto.Unmarshal(data, &decodedStatus)
assert(err == nil, "proto.Unmarshal should succeed")
assert(decodedStatus.GetCode() == int32(code.Code_UNAVAILABLE), "status code should match UNAVAILABLE")
assert(len(decodedStatus.GetDetails()) == 1, "details count should be 1")
// 4. RetryInfo handles nil RetryDelay safely returning nil
nilRetryInfo := &errdetails.RetryInfo{}
assert(nilRetryInfo.GetRetryDelay() == nil, "GetRetryDelay on empty RetryInfo should return nil")
var typedNil *errdetails.RetryInfo
assert(typedNil.GetRetryDelay() == nil, "GetRetryDelay on typed nil should return nil")
// 5. RetryInfo message matches anypb.MessageIs type check
assert(anyMsg.MessageIs(&errdetails.RetryInfo{}), "MessageIs should return true for RetryInfo")
assert(!anyMsg.MessageIs(&errdetails.BadRequest{}), "MessageIs should return false for BadRequest")
fmt.Println("All contract assertions passed successfully.")
}
Ursprungs-Seeder
anonym