Пример
google.golang.org/genproto/googleapis/rpc v0.0.0-20241007155032-5fefd90f89a9: errdetails.ResourceInfo
Проверенный пример — golang google.golang.org/genproto/googleapis/rpc v0.0.0-20241007155032-5fefd90f89a9: errdetails.ResourceInfo. Контракт выполнен на go…
sha256:177cf900f143e9336b8adf199d3539df476e050512ad96f6198abedbdd9546a3
Эта сеть предлагает одно: образец, который собирается. Она запустила его в песочнице и сохранила подписанную квитанцию. Она ничего не оценивает и ничего не гарантирует — собирается ли тот же код у вас, она не измеряла.
Сколько различных ключей подписи подали пройденную квитанцию контракта. Один — только автор; больше одного — значит, кто-то ещё тоже собрал. Ключ создаётся сам и не имеет зарегистрированной личности, поэтому считаются ключи, а не люди.
MIT-0
Свидетельства выполнения
Заявленное окружение и подписанные запуски разделены, чтобы вы точно видели, что этот образец запускал и где.
- Основа свидетельства
- Подписанный контракт пройден
- Квитанции проверки
- 1
- Ключи подписи, собравшие его
- 1
Заявленная среда
linux 24 · ubuntu · glibc 2.39 x64 go
Среды запусков проверки
| Окружение | Контракт | Этапы | Запуск |
|---|---|---|---|
| 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 |
Кейс
HOW- Цель
- verify google.golang.org/genproto/googleapis/rpc/errdetails.ResourceInfo in pkg:golang/google.golang.org/genproto/googleapis/rpc@v0.0.0-20241007155032-5fefd90f89a9
- Символы
-
- google.golang.org/genproto/googleapis/rpc/errdetails.ResourceInfo
- Создан
- 2026-08-27T11:54:47Z
Контракт
- ResourceInfo correctly stores and returns ResourceType, ResourceName, Owner, and Description fields
- Getters return safe empty string defaults when called on a nil ResourceInfo pointer
- ResourceInfo correctly serializes to and deserializes from protocol buffer binary format
- Reset clears all fields of a ResourceInfo instance to their zero values
- ProtoReflect returns a valid Message descriptor matching google.rpc.ResourceInfo full name
Файлы
- 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/rpc/errdetails.ResourceInfo 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.ResourceInfo
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:0203997b94c29258593a12ddd9b006871087ad1e6e499b01aaf4612f65515d4d","contract":["ResourceInfo correctly stores and returns ResourceType, ResourceName, Owner, and Description fields","Getters return safe empty string defaults when called on a nil ResourceInfo pointer","ResourceInfo correctly serializes to and deserializes from protocol buffer binary format","Reset clears all fields of a ResourceInfo instance to their zero values","ProtoReflect returns a valid Message descriptor matching google.rpc.ResourceInfo full name"],"goal":"verify google.golang.org/genproto/googleapis/rpc/errdetails.ResourceInfo 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.ResourceInfo"]},"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.ResourceInfo"],"verifierAdapter":"golang@1"}
module example.com/sample
go 1.25.0
require (
google.golang.org/genproto/googleapis/rpc v0.0.0-20241007155032-5fefd90f89a9
google.golang.org/protobuf v1.36.12
)
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/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.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/rpc/errdetails"
"google.golang.org/protobuf/proto"
)
// CreateResourceInfo creates a ResourceInfo instance with the given details.
func CreateResourceInfo(resourceType, resourceName, owner, description string) *errdetails.ResourceInfo {
return &errdetails.ResourceInfo{
ResourceType: resourceType,
ResourceName: resourceName,
Owner: owner,
Description: description,
}
}
// MarshalResourceInfo serializes a ResourceInfo proto message to binary.
func MarshalResourceInfo(info *errdetails.ResourceInfo) ([]byte, error) {
return proto.Marshal(info)
}
// UnmarshalResourceInfo deserializes binary data into a ResourceInfo proto message.
func UnmarshalResourceInfo(data []byte) (*errdetails.ResourceInfo, error) {
var info errdetails.ResourceInfo
if err := proto.Unmarshal(data, &info); err != nil {
return nil, err
}
return &info, nil
}
func main() {
info := CreateResourceInfo(
"type.googleapis.com/example.Database",
"projects/example-project/databases/db-1",
"admin@example.com",
"Database resource quota exceeded",
)
fmt.Printf("Resource Type: %s\n", info.GetResourceType())
fmt.Printf("Resource Name: %s\n", info.GetResourceName())
fmt.Printf("Owner: %s\n", info.GetOwner())
fmt.Printf("Description: %s\n", info.GetDescription())
data, err := MarshalResourceInfo(info)
if err != nil {
panic(err)
}
decoded, err := UnmarshalResourceInfo(data)
if err != nil {
panic(err)
}
fmt.Printf("Decoded Resource: %s\n", decoded.GetResourceName())
}
{
"schemaVersion": 1,
"goal": "verify google.golang.org/genproto/googleapis/rpc/errdetails.ResourceInfo 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.ResourceInfo"
]
}
package main
import (
"fmt"
"os"
"google.golang.org/genproto/googleapis/rpc/errdetails"
"google.golang.org/protobuf/proto"
"google.golang.org/protobuf/reflect/protoreflect"
)
func main() {
// Assertion 1: ResourceInfo correctly stores and returns ResourceType, ResourceName, Owner, and Description fields
res := &errdetails.ResourceInfo{
ResourceType: "storage.googleapis.com/Bucket",
ResourceName: "projects/sample-project/buckets/data-store",
Owner: "service-admin",
Description: "Sample bucket resource",
}
if got := res.GetResourceType(); got != "storage.googleapis.com/Bucket" {
fmt.Fprintf(os.Stderr, "FAIL: GetResourceType mismatch: got %q, want %q\n", got, "storage.googleapis.com/Bucket")
os.Exit(1)
}
if got := res.GetResourceName(); got != "projects/sample-project/buckets/data-store" {
fmt.Fprintf(os.Stderr, "FAIL: GetResourceName mismatch: got %q, want %q\n", got, "projects/sample-project/buckets/data-store")
os.Exit(1)
}
if got := res.GetOwner(); got != "service-admin" {
fmt.Fprintf(os.Stderr, "FAIL: GetOwner mismatch: got %q, want %q\n", got, "service-admin")
os.Exit(1)
}
if got := res.GetDescription(); got != "Sample bucket resource" {
fmt.Fprintf(os.Stderr, "FAIL: GetDescription mismatch: got %q, want %q\n", got, "Sample bucket resource")
os.Exit(1)
}
// Assertion 2: Getters return safe empty string defaults when called on a nil ResourceInfo pointer
var nilRes *errdetails.ResourceInfo
if got := nilRes.GetResourceType(); got != "" {
fmt.Fprintf(os.Stderr, "FAIL: nil GetResourceType expected empty string, got %q\n", got)
os.Exit(1)
}
if got := nilRes.GetResourceName(); got != "" {
fmt.Fprintf(os.Stderr, "FAIL: nil GetResourceName expected empty string, got %q\n", got)
os.Exit(1)
}
if got := nilRes.GetOwner(); got != "" {
fmt.Fprintf(os.Stderr, "FAIL: nil GetOwner expected empty string, got %q\n", got)
os.Exit(1)
}
if got := nilRes.GetDescription(); got != "" {
fmt.Fprintf(os.Stderr, "FAIL: nil GetDescription expected empty string, got %q\n", got)
os.Exit(1)
}
// Assertion 3: ResourceInfo correctly serializes to and deserializes from protocol buffer binary format
data, err := proto.Marshal(res)
if err != nil {
fmt.Fprintf(os.Stderr, "FAIL: proto.Marshal failed: %v\n", err)
os.Exit(1)
}
if len(data) == 0 {
fmt.Fprintf(os.Stderr, "FAIL: marshaled proto data is empty\n")
os.Exit(1)
}
var unmarshaled errdetails.ResourceInfo
if err := proto.Unmarshal(data, &unmarshaled); err != nil {
fmt.Fprintf(os.Stderr, "FAIL: proto.Unmarshal failed: %v\n", err)
os.Exit(1)
}
if !proto.Equal(res, &unmarshaled) {
fmt.Fprintf(os.Stderr, "FAIL: unmarshaled proto does not equal original\n")
os.Exit(1)
}
// Assertion 4: Reset clears all fields of a ResourceInfo instance to their zero values
copyRes := &errdetails.ResourceInfo{
ResourceType: "compute.googleapis.com/Instance",
ResourceName: "projects/sample-project/zones/us-central1-a/instances/worker-1",
Owner: "ops-team",
Description: "Compute engine instance",
}
copyRes.Reset()
if copyRes.GetResourceType() != "" || copyRes.GetResourceName() != "" || copyRes.GetOwner() != "" || copyRes.GetDescription() != "" {
fmt.Fprintf(os.Stderr, "FAIL: Reset failed to clear all fields\n")
os.Exit(1)
}
// Assertion 5: ProtoReflect returns a valid Message descriptor matching google.rpc.ResourceInfo full name
msg := res.ProtoReflect()
descriptor := msg.Descriptor()
if string(descriptor.FullName()) != "google.rpc.ResourceInfo" {
fmt.Fprintf(os.Stderr, "FAIL: Descriptor FullName mismatch: got %q, want %q\n", descriptor.FullName(), "google.rpc.ResourceInfo")
os.Exit(1)
}
resTypeField := descriptor.Fields().ByName(protoreflect.Name("resource_type"))
if resTypeField == nil {
fmt.Fprintf(os.Stderr, "FAIL: field descriptor for resource_type not found\n")
os.Exit(1)
}
fmt.Println("PASS: google.golang.org/genproto/googleapis/rpc/errdetails.ResourceInfo contract verified")
}
Исходный сидер
аноним