샘플
google.golang.org/genproto/googleapis/api v0.0.0-20241007155032-5fefd90f89a9: annotations.E_Http
검증된 샘플 — golang google.golang.org/genproto/googleapis/api v0.0.0-20241007155032-5fefd90f89a9: annotations.E_Http. go 1.26 · linux alpine/x64 · docker에서…
sha256:7d1b51d2caea12002e4aa10880e9c12d495020818b67d930abab912d5a10dab7
이 네트워크가 제공하는 것은 하나입니다. 빌드되는 샘플. 샌드박스에서 돌리고 서명된 영수증을 보관합니다. 등급을 매기지 않고 무엇도 보증하지 않습니다 — 같은 코드가 당신 환경에서 빌드되는지는 측정한 적이 없습니다.
통과한 계약 영수증을 낸 서로 다른 서명 키의 수입니다. 하나면 작성자 혼자이고, 둘 이상이면 다른 사람도 빌드했다는 뜻입니다. 키는 스스로 만드는 것이고 뒤에 등록된 신원이 없으므로, 세는 것은 사람이 아니라 키입니다.
MIT-0
실행 증거
선언된 환경과 서명된 실행을 분리해 두었습니다. 이 샘플이 무엇을 어디서 실행했는지 그대로 볼 수 있습니다.
- 증거 기준
- 서명된 컨트랙트 통과
- 검증 영수증
- 2
- 빌드한 서명 키
- 1
선언된 환경
linux 24 · ubuntu · glibc 2.39 x64 go
검증 실행 환경
| 환경 | 컨트랙트 | 단계 | 실행일 |
|---|---|---|---|
| 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 |
케이스
HOW- 목표
- verify google.golang.org/genproto/googleapis/api/annotations.E_Http in pkg:golang/google.golang.org/genproto/googleapis/api@v0.0.0-20241007155032-5fefd90f89a9
- 심벌
-
- google.golang.org/genproto/googleapis/api/annotations.E_Http
- 생성일
- 2026-08-30T16:56:15Z
컨트랙트
- 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
파일
- PROMPT.md
- csx.json
- go.mod
- go.sum
- main.go
- spec.json
- test/contract.go
소스
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")
}
오리진 시더
익명