CodeSampleX

Beispiel

google.golang.org/genproto/googleapis/api v0.0.0-20241007155032-5fefd90f89a9: annotations.HttpRule_Delete

Verifiziertes Beispiel für golang google.golang.org/genproto/googleapis/api v0.0.0-20241007155032-5fefd90f89a9: annotations.HttpRule_Delete. Der Vertrag lief…

sha256:5c6e4cf36365b24089e28bb11da468bcfa4c10ef4996bcb2d8da0e68d522db4c

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/api/annotations.HttpRule_Delete in pkg:golang/google.golang.org/genproto/googleapis/api@v0.0.0-20241007155032-5fefd90f89a9
Pakete
Symbole
  • google.golang.org/genproto/googleapis/api/annotations.HttpRule_Delete
Erstellt
2026-08-27T12:02:07Z

Contract

  1. HttpRule_Delete sets and gets the DELETE endpoint URL pattern on HttpRule
  2. HttpRule_Delete serializes and deserializes correctly via proto.Marshal and proto.Unmarshal
  3. HttpRule with nil or non-Delete pattern returns empty string from GetDelete
  4. HttpRule_Delete can be used within AdditionalBindings on HttpRule
  5. HttpRule_Delete works within proto cloning and equality

Dateien

  • PROMPT.md
  • csx.json
  • go.mod
  • go.sum
  • main.go
  • spec.json
  • test/contract.go

Quellartefakt herunterladen (tar.gz)

Quelltext

PROMPT.md
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.HttpRule_Delete 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.HttpRule_Delete

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.
csx.json
{"case":{"caseId":"case:sha256:5170c3b304293c5e8dca15f33e4cf54272e57aaa94185b9ccc7aacfd81f00295","contract":["HttpRule_Delete sets and gets the DELETE endpoint URL pattern on HttpRule","HttpRule_Delete serializes and deserializes correctly via proto.Marshal and proto.Unmarshal","HttpRule with nil or non-Delete pattern returns empty string from GetDelete","HttpRule_Delete can be used within AdditionalBindings on HttpRule","HttpRule_Delete works within proto cloning and equality"],"goal":"verify google.golang.org/genproto/googleapis/api/annotations.HttpRule_Delete 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.HttpRule_Delete"]},"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.HttpRule_Delete"],"verifierAdapter":"golang@1"}
go.mod
module example.com/sample

go 1.22

require (
	google.golang.org/genproto/googleapis/api v0.0.0-20241007155032-5fefd90f89a9
	google.golang.org/protobuf v1.35.1
)
go.sum
github.com/google/go-cmp v0.5.5 h1:Khx7svrCpmxxtHBq5j2mp/xVjsi8hQMfNLvJFAlrGgU=
github.com/google/go-cmp v0.5.5/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/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/protobuf v1.35.1 h1:m3LfL6/Ca+fqnjnlqQXNpFPABW1UD7mjh8KO2mKFytA=
google.golang.org/protobuf v1.35.1/go.mod h1:9fA7Ob0pmnwhb644+1+CVWFRbNajQ6iRojtC/QF5bRE=
main.go
package main

import (
	"fmt"

	"google.golang.org/genproto/googleapis/api/annotations"
	"google.golang.org/protobuf/proto"
)

func main() {
	rule := &annotations.HttpRule{
		Selector: "example.v1.ResourceService.DeleteResource",
		Pattern: &annotations.HttpRule_Delete{
			Delete: "/v1/resources/{id}",
		},
	}

	fmt.Printf("Selector: %s\n", rule.GetSelector())
	fmt.Printf("Delete Pattern: %s\n", rule.GetDelete())

	if del, ok := rule.GetPattern().(*annotations.HttpRule_Delete); ok {
		fmt.Printf("Pattern direct field: %s\n", del.Delete)
	}

	data, err := proto.Marshal(rule)
	if err != nil {
		panic(err)
	}

	var decoded annotations.HttpRule
	if err := proto.Unmarshal(data, &decoded); err != nil {
		panic(err)
	}

	fmt.Printf("Decoded Delete Pattern: %s\n", decoded.GetDelete())
}
spec.json
{
  "schemaVersion": 1,
  "goal": "verify google.golang.org/genproto/googleapis/api/annotations.HttpRule_Delete 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.HttpRule_Delete"
  ]
}
test/contract.go
package main

import (
	"fmt"
	"os"

	"google.golang.org/genproto/googleapis/api/annotations"
	"google.golang.org/protobuf/proto"
)

func assert(condition bool, message string) {
	if !condition {
		fmt.Fprintf(os.Stderr, "Assertion failed: %s\n", message)
		os.Exit(1)
	}
}

func main() {
	// 1. HttpRule_Delete sets and gets the DELETE endpoint URL pattern on HttpRule
	rule := &annotations.HttpRule{
		Selector: "example.v1.ResourceService.DeleteResource",
		Pattern: &annotations.HttpRule_Delete{
			Delete: "/v1/resources/{id}",
		},
	}
	assert(rule.GetSelector() == "example.v1.ResourceService.DeleteResource", "selector should match")
	assert(rule.GetDelete() == "/v1/resources/{id}", "GetDelete should return the URL template")

	delPattern, ok := rule.GetPattern().(*annotations.HttpRule_Delete)
	assert(ok, "Pattern should type-assert to *annotations.HttpRule_Delete")
	assert(delPattern != nil, "delPattern must not be nil")
	assert(delPattern.Delete == "/v1/resources/{id}", "delPattern.Delete must match the assigned string")

	// 2. HttpRule_Delete serializes and deserializes correctly via proto.Marshal and proto.Unmarshal
	data, err := proto.Marshal(rule)
	assert(err == nil, "proto.Marshal should succeed")
	assert(len(data) > 0, "marshaled payload should not be empty")

	var decoded annotations.HttpRule
	err = proto.Unmarshal(data, &decoded)
	assert(err == nil, "proto.Unmarshal should succeed")
	assert(decoded.GetSelector() == "example.v1.ResourceService.DeleteResource", "unmarshaled selector must match")
	assert(decoded.GetDelete() == "/v1/resources/{id}", "unmarshaled GetDelete must match")

	decodedDel, ok := decoded.GetPattern().(*annotations.HttpRule_Delete)
	assert(ok, "decoded Pattern must type-assert to *annotations.HttpRule_Delete")
	assert(decodedDel.Delete == "/v1/resources/{id}", "decodedDel.Delete must match")

	// 3. HttpRule with nil or non-Delete pattern returns empty string from GetDelete
	var nilRule *annotations.HttpRule
	assert(nilRule.GetDelete() == "", "nil HttpRule GetDelete must return empty string")

	emptyRule := &annotations.HttpRule{}
	assert(emptyRule.GetDelete() == "", "empty HttpRule GetDelete must return empty string")
	assert(emptyRule.GetPattern() == nil, "empty HttpRule GetPattern must be nil")

	getRule := &annotations.HttpRule{
		Pattern: &annotations.HttpRule_Get{
			Get: "/v1/resources/{id}",
		},
	}
	assert(getRule.GetDelete() == "", "HttpRule with Get pattern must return empty string from GetDelete")
	assert(getRule.GetGet() == "/v1/resources/{id}", "HttpRule GetGet must return GET path")

	// 4. HttpRule_Delete can be used within AdditionalBindings on HttpRule
	parentRule := &annotations.HttpRule{
		Selector: "example.v1.ResourceService.ManageResource",
		Pattern: &annotations.HttpRule_Post{
			Post: "/v1/resources/{id}:action",
		},
		AdditionalBindings: []*annotations.HttpRule{
			{
				Pattern: &annotations.HttpRule_Delete{
					Delete: "/v1/resources/{id}",
				},
			},
		},
	}
	assert(len(parentRule.GetAdditionalBindings()) == 1, "additional bindings count should be 1")
	assert(parentRule.GetAdditionalBindings()[0].GetDelete() == "/v1/resources/{id}", "additional binding GetDelete should match")

	// 5. HttpRule_Delete works within proto cloning and equality
	cloned := proto.Clone(rule).(*annotations.HttpRule)
	assert(proto.Equal(rule, cloned), "cloned rule should be proto.Equal to original")
	assert(cloned.GetDelete() == "/v1/resources/{id}", "cloned rule GetDelete should match")
}

Ursprungs-Seeder

anonym