Beispiel
google.golang.org/genproto/googleapis/api v0.0.0-20241007155032-5fefd90f89a9: annotations.E_Http
Verifiziertes Beispiel für golang google.golang.org/genproto/googleapis/api v0.0.0-20241007155032-5fefd90f89a9: annotations.E_Http. Der Vertrag lief auf go…
sha256:7d1b51d2caea12002e4aa10880e9c12d495020818b67d930abab912d5a10dab7
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
- 2
- 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 | FAIL | compile:SKIPPED · contract:FAIL · load:SKIPPED · resolve:PASS CONTAINER_RUN · golang@1golang:1.26-alpine@sha256:28d89ee9cc0f… |
2026-08-30 |
| go 1.26 · linux alpine/x64 · docker ed25519:d91480838ac982c9 | PASS | compile:SKIPPED · contract:PASS · load:PASS · resolve:PASS CONTAINER_RUN · golang@1golang:1.26-alpine@sha256:28d89ee9cc0f… |
2026-08-30 |
Fall
HOW- Ziel
- verify google.golang.org/genproto/googleapis/api/annotations.E_Http in pkg:golang/google.golang.org/genproto/googleapis/api@v0.0.0-20241007155032-5fefd90f89a9
- Symbole
-
- google.golang.org/genproto/googleapis/api/annotations.E_Http
- Erstellt
- 2026-08-30T16:56:15Z
Contract
- annotations.E_Http extension descriptor targets google.protobuf.MethodOptions with extension number 72295728
- proto.HasExtension returns true when annotations.E_Http is set on MethodOptions and false when unset
- proto.GetExtension retrieves configured HttpRule with GET path pattern from MethodOptions
- proto.GetExtension retrieves configured HttpRule with POST path, body selector and additional bindings
- proto.ClearExtension removes annotations.E_Http from MethodOptions
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/api/annotations.E_Http in pkg:golang/google.golang.org/genproto/googleapis/api@v0.0.0-20241007155032-5fefd90f89a9
Kind: HOW
Use EXACTLY these public packages and versions:
- pkg:golang/google.golang.org/genproto/googleapis/api@v0.0.0-20241007155032-5fefd90f89a9
Demonstrate these symbols/APIs:
- google.golang.org/genproto/googleapis/api/annotations.E_Http
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:9ba13af220039cb99576ac2d98ce3d714375ba64ae6ca7de7ef07cb32721bfa5","contract":["annotations.E_Http extension descriptor targets google.protobuf.MethodOptions with extension number 72295728","proto.HasExtension returns true when annotations.E_Http is set on MethodOptions and false when unset","proto.GetExtension retrieves configured HttpRule with GET path pattern from MethodOptions","proto.GetExtension retrieves configured HttpRule with POST path, body selector and additional bindings","proto.ClearExtension removes annotations.E_Http from MethodOptions"],"goal":"verify google.golang.org/genproto/googleapis/api/annotations.E_Http in pkg:golang/google.golang.org/genproto/googleapis/api@v0.0.0-20241007155032-5fefd90f89a9","kind":"HOW","packages":["pkg:golang/google.golang.org/genproto/googleapis/api@v0.0.0-20241007155032-5fefd90f89a9"],"schemaVersion":1,"symbols":["google.golang.org/genproto/googleapis/api/annotations.E_Http"]},"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/api@v0.0.0-20241007155032-5fefd90f89a9"],"schemaVersion":1,"subject":"pkg:golang/google.golang.org/genproto/googleapis/api@v0.0.0-20241007155032-5fefd90f89a9","symbols":["google.golang.org/genproto/googleapis/api/annotations.E_Http"],"verifierAdapter":"golang@1"}
module example.com/sample
go 1.22.0
require (
google.golang.org/genproto/googleapis/api v0.0.0-20241007155032-5fefd90f89a9
google.golang.org/protobuf v1.35.1
)
github.com/google/go-cmp v0.7.0 h1:wk8382ETsv4JYUZwIsn6YpYiWiBsYLSJiTsyBybVuN8=
github.com/google/go-cmp v0.7.0/go.mod h1:pXiqmnSA92OHEEa9HXL2W4E7lf9JzCmGVUdgjX3N/iU=
google.golang.org/genproto/googleapis/api v0.0.0-20241007155032-5fefd90f89a9 h1:T6rh4haD3GVYsgEfWExoCZA2o2FmbNyKpTuAxbEFPTg=
google.golang.org/genproto/googleapis/api v0.0.0-20241007155032-5fefd90f89a9/go.mod h1:wp2WsuBYj6j8wUdo3ToZsdxxixbvQNAHqVJrTgi5E5M=
google.golang.org/genproto/googleapis/api v0.0.0-20260825221802-da73d73af1c5 h1:izFU9hz7aeLI/Mi1J0991ae+xcwRLr7hTqWnB/9aIIU=
google.golang.org/genproto/googleapis/api v0.0.0-20260825221802-da73d73af1c5/go.mod h1:3LhxRw4YYkf+ylAfgaY9JlVLFKhokkCV8duhLLe7+t0=
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=
google.golang.org/protobuf v1.36.12 h1:pJOKDDOyeXErUroCihFAd5LQuwXBSpVnKGrj5o/fwxc=
google.golang.org/protobuf v1.36.12/go.mod h1:HTf+CrKn2C3g5S8VImy6tdcUvCska2kB7j23XfzDpco=
package main
import (
"fmt"
"google.golang.org/genproto/googleapis/api/annotations"
"google.golang.org/protobuf/proto"
"google.golang.org/protobuf/types/descriptorpb"
)
// AttachHttpRule attaches a google.api.http rule to method options via E_Http extension.
func AttachHttpRule(opts *descriptorpb.MethodOptions, rule *annotations.HttpRule) {
proto.SetExtension(opts, annotations.E_Http, rule)
}
// ExtractHttpRule retrieves a google.api.http rule from method options if present.
func ExtractHttpRule(opts *descriptorpb.MethodOptions) (*annotations.HttpRule, bool) {
if !proto.HasExtension(opts, annotations.E_Http) {
return nil, false
}
ext := proto.GetExtension(opts, annotations.E_Http)
rule, ok := ext.(*annotations.HttpRule)
return rule, ok
}
func main() {
opts := &descriptorpb.MethodOptions{}
rule := &annotations.HttpRule{
Pattern: &annotations.HttpRule_Get{
Get: "/v1/messages/{message_id}",
},
Body: "",
}
AttachHttpRule(opts, rule)
extracted, ok := ExtractHttpRule(opts)
if !ok || extracted == nil {
fmt.Println("Failed to extract HTTP rule")
return
}
fmt.Printf("HTTP Method GET Path: %s\n", extracted.GetGet())
}
{
"schemaVersion": 1,
"goal": "verify google.golang.org/genproto/googleapis/api/annotations.E_Http in pkg:golang/google.golang.org/genproto/googleapis/api@v0.0.0-20241007155032-5fefd90f89a9",
"kind": "HOW",
"packages": [
"pkg:golang/google.golang.org/genproto/googleapis/api@v0.0.0-20241007155032-5fefd90f89a9"
],
"symbols": [
"google.golang.org/genproto/googleapis/api/annotations.E_Http"
]
}
package main
import (
"fmt"
"os"
"google.golang.org/genproto/googleapis/api/annotations"
"google.golang.org/protobuf/proto"
"google.golang.org/protobuf/types/descriptorpb"
)
func main() {
// Assertion 1: annotations.E_Http extension descriptor targets google.protobuf.MethodOptions
extDesc := annotations.E_Http.TypeDescriptor()
if extDesc == nil {
fmt.Fprintf(os.Stderr, "FAIL: annotations.E_Http TypeDescriptor is nil\n")
os.Exit(1)
}
extTarget := string(extDesc.ContainingMessage().FullName())
if extTarget != "google.protobuf.MethodOptions" {
fmt.Fprintf(os.Stderr, "FAIL: expected extension target google.protobuf.MethodOptions, got %s\n", extTarget)
os.Exit(1)
}
extNumber := int(extDesc.Number())
if extNumber != 72295728 {
fmt.Fprintf(os.Stderr, "FAIL: expected extension number 72295728, got %d\n", extNumber)
os.Exit(1)
}
// Assertion 2: proto.HasExtension returns true when annotations.E_Http is set on MethodOptions and false when unset
emptyOpts := &descriptorpb.MethodOptions{}
if proto.HasExtension(emptyOpts, annotations.E_Http) {
fmt.Fprintf(os.Stderr, "FAIL: HasExtension returned true for empty MethodOptions\n")
os.Exit(1)
}
optsWithExt := &descriptorpb.MethodOptions{}
ruleGet := &annotations.HttpRule{
Pattern: &annotations.HttpRule_Get{
Get: "/v1/books/{book_id}",
},
}
proto.SetExtension(optsWithExt, annotations.E_Http, ruleGet)
if !proto.HasExtension(optsWithExt, annotations.E_Http) {
fmt.Fprintf(os.Stderr, "FAIL: HasExtension returned false after SetExtension\n")
os.Exit(1)
}
// Assertion 3: proto.GetExtension retrieves configured HttpRule with GET path pattern
extVal := proto.GetExtension(optsWithExt, annotations.E_Http)
retrievedRule, ok := extVal.(*annotations.HttpRule)
if !ok || retrievedRule == nil {
fmt.Fprintf(os.Stderr, "FAIL: GetExtension did not return *annotations.HttpRule\n")
os.Exit(1)
}
if retrievedRule.GetGet() != "/v1/books/{book_id}" {
fmt.Fprintf(os.Stderr, "FAIL: expected GET path /v1/books/{book_id}, got %s\n", retrievedRule.GetGet())
os.Exit(1)
}
// Assertion 4: proto.GetExtension retrieves configured HttpRule with POST path, body selector and additional bindings
optsComplex := &descriptorpb.MethodOptions{}
rulePost := &annotations.HttpRule{
Pattern: &annotations.HttpRule_Post{
Post: "/v1/books",
},
Body: "*",
AdditionalBindings: []*annotations.HttpRule{
{
Pattern: &annotations.HttpRule_Put{
Put: "/v1/books/{book_id}",
},
Body: "book",
},
},
}
proto.SetExtension(optsComplex, annotations.E_Http, rulePost)
complexVal := proto.GetExtension(optsComplex, annotations.E_Http)
complexRule, ok := complexVal.(*annotations.HttpRule)
if !ok || complexRule == nil {
fmt.Fprintf(os.Stderr, "FAIL: failed to retrieve complex HttpRule\n")
os.Exit(1)
}
if complexRule.GetPost() != "/v1/books" || complexRule.GetBody() != "*" {
fmt.Fprintf(os.Stderr, "FAIL: mismatch in POST path or body\n")
os.Exit(1)
}
if len(complexRule.GetAdditionalBindings()) != 1 || complexRule.GetAdditionalBindings()[0].GetPut() != "/v1/books/{book_id}" {
fmt.Fprintf(os.Stderr, "FAIL: mismatch in AdditionalBindings\n")
os.Exit(1)
}
// Assertion 5: proto.ClearExtension removes annotations.E_Http from MethodOptions
proto.ClearExtension(optsWithExt, annotations.E_Http)
if proto.HasExtension(optsWithExt, annotations.E_Http) {
fmt.Fprintf(os.Stderr, "FAIL: HasExtension returned true after ClearExtension\n")
os.Exit(1)
}
fmt.Println("PASS: google.golang.org/genproto/googleapis/api/annotations.E_Http contract verified")
}
Ursprungs-Seeder
anonym