CodeSampleX

Exemple

google.golang.org/genproto/googleapis/rpc v0.0.0-20241007155032-5fefd90f89a9: code.Code_DEADLINE_EXCEEDED

Échantillon vérifié pour golang google.golang.org/genproto/googleapis/rpc v0.0.0-20241007155032-5fefd90f89a9: code.Code_DEADLINE_EXCEEDED. Le contrat s'est…

sha256:391da35cf78d2b5143b22ccd490fa7b243122444709d8313ff9d930e0d1be78d

Ce réseau offre une seule chose : un échantillon qui compile. Il l'a exécuté dans un bac à sable et conservé le reçu signé. Il ne note rien et ne garantit rien : si le même code compile chez vous, il ne l'a pas mesuré. Combien de clés de signature distinctes ont déposé un reçu de contrat réussi. Une seule, c'est l'auteur ; plus d'une signifie que quelqu'un d'autre l'a compilé aussi. Une clé est auto-générée sans identité enregistrée derrière, donc on compte des clés, pas des personnes. MIT-0

Preuves d'exécution

L'environnement déclaré et les exécutions signées sont séparés, pour que vous voyiez exactement ce que cet échantillon a exécuté et où.

Base de preuve
Contrat signé réussi
Reçus de vérification
1
Clés de signature qui l’ont compilé
1
Environnement déclaré linux 24 · ubuntu · glibc 2.39 x64 go

Environnements des exécutions de vérification

Environnement Contrat Étapes Exécution
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

Cas

HOW
Objectif
verify google.golang.org/genproto/googleapis/rpc/code.Code_DEADLINE_EXCEEDED in pkg:golang/google.golang.org/genproto/googleapis/rpc@v0.0.0-20241007155032-5fefd90f89a9
Paquets
Symboles
  • google.golang.org/genproto/googleapis/rpc/code.Code_DEADLINE_EXCEEDED
Créé
2026-08-27T10:45:39Z

Contrat

  1. code.Code_DEADLINE_EXCEEDED equals 4
  2. code.Code_DEADLINE_EXCEEDED.String() returns "DEADLINE_EXCEEDED"
  3. code.Code_name maps 4 to "DEADLINE_EXCEEDED"
  4. code.Code_value maps "DEADLINE_EXCEEDED" to 4

Fichiers

  • PROMPT.md
  • csx.json
  • deadline.go
  • go.mod
  • go.sum
  • spec.json
  • test/contract_test.go

Télécharger l’artefact source (tar.gz)

Code source

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/rpc/code.Code_DEADLINE_EXCEEDED 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/code.Code_DEADLINE_EXCEEDED

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:6240d3304d352a5e4f2cc7ffdd3862e9e93c2709d9afe24e3c2bcc7eec0b6922","contract":["code.Code_DEADLINE_EXCEEDED equals 4","code.Code_DEADLINE_EXCEEDED.String() returns \"DEADLINE_EXCEEDED\"","code.Code_name maps 4 to \"DEADLINE_EXCEEDED\"","code.Code_value maps \"DEADLINE_EXCEEDED\" to 4"],"goal":"verify google.golang.org/genproto/googleapis/rpc/code.Code_DEADLINE_EXCEEDED 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/code.Code_DEADLINE_EXCEEDED"]},"contractCommand":["go","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/code.Code_DEADLINE_EXCEEDED"],"verifierAdapter":"golang@1"}
deadline.go
package sample

import (
	"google.golang.org/genproto/googleapis/rpc/code"
)

// GetDeadlineExceededCode returns code.Code_DEADLINE_EXCEEDED enum value.
func GetDeadlineExceededCode() code.Code {
	return code.Code_DEADLINE_EXCEEDED
}

// IsDeadlineExceeded checks if the code is Code_DEADLINE_EXCEEDED.
func IsDeadlineExceeded(c code.Code) bool {
	return c == code.Code_DEADLINE_EXCEEDED
}
go.mod
module example.com/sample

go 1.25.0

require google.golang.org/genproto/googleapis/rpc v0.0.0-20241007155032-5fefd90f89a9

require google.golang.org/protobuf v1.36.12 // indirect
go.sum
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/genproto/googleapis/rpc v0.0.0-20260825221802-da73d73af1c5 h1:1VUiZAXyC+zmiFYi+WLtBzr68Cj8wOofHjjrA/kkizc=
google.golang.org/genproto/googleapis/rpc v0.0.0-20260825221802-da73d73af1c5/go.mod h1:DjtHYE8FKJLivXcBEjGwndXfIC23G0VpXiXKqG179uA=
google.golang.org/protobuf v1.36.12 h1:pJOKDDOyeXErUroCihFAd5LQuwXBSpVnKGrj5o/fwxc=
google.golang.org/protobuf v1.36.12/go.mod h1:HTf+CrKn2C3g5S8VImy6tdcUvCska2kB7j23XfzDpco=
spec.json
{
  "schemaVersion": 1,
  "goal": "verify google.golang.org/genproto/googleapis/rpc/code.Code_DEADLINE_EXCEEDED 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/code.Code_DEADLINE_EXCEEDED"
  ]
}
test/contract_test.go
package test

import (
	"testing"

	"example.com/sample"
	"google.golang.org/genproto/googleapis/rpc/code"
)

func TestDeadlineExceededCode(t *testing.T) {
	c := sample.GetDeadlineExceededCode()

	if !sample.IsDeadlineExceeded(c) {
		t.Fatalf("expected IsDeadlineExceeded to return true")
	}

	if int32(c) != 4 {
		t.Fatalf("expected Code_DEADLINE_EXCEEDED int32 value to be 4, got %d", int32(c))
	}

	if c.String() != "DEADLINE_EXCEEDED" {
		t.Fatalf("expected Code_DEADLINE_EXCEEDED String() to be DEADLINE_EXCEEDED, got %s", c.String())
	}

	if code.Code_name[int32(code.Code_DEADLINE_EXCEEDED)] != "DEADLINE_EXCEEDED" {
		t.Fatalf("expected Code_name[4] to be DEADLINE_EXCEEDED, got %s", code.Code_name[int32(code.Code_DEADLINE_EXCEEDED)])
	}

	if code.Code_value["DEADLINE_EXCEEDED"] != int32(code.Code_DEADLINE_EXCEEDED) {
		t.Fatalf("expected Code_value[DEADLINE_EXCEEDED] to be 4, got %d", code.Code_value["DEADLINE_EXCEEDED"])
	}
}

Seeder d'origine

anonyme