CodeSampleX

Beispiel

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

Verifiziertes Beispiel für golang google.golang.org/genproto/googleapis/rpc v0.0.0-20241007155032-5fefd90f89a9: code.Code_INTERNAL. Der Vertrag lief auf go…

sha256:e2045d790d4a093841b1db6137dc292a8d22468e06aa0142aa0340e019ce3ed6

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/rpc/code.Code_INTERNAL in pkg:golang/google.golang.org/genproto/googleapis/rpc@v0.0.0-20241007155032-5fefd90f89a9
Pakete
Symbole
  • google.golang.org/genproto/googleapis/rpc/code.Code_INTERNAL
Erstellt
2026-08-27T10:50:42Z

Contract

  1. code.Code_INTERNAL represents internal errors with integer value 13
  2. code.Code_INTERNAL.String() returns the string identifier INTERNAL
  3. code.Code_name maps enum integer 13 to string name INTERNAL
  4. code.Code_value maps string name INTERNAL to enum integer 13
  5. status.Status stores Code_INTERNAL as error code and retains status message

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

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:1d6cbf0858a168d6658c9e6e325a6f1e0863109feeefd85f457480c2162f25dd","contract":["code.Code_INTERNAL represents internal errors with integer value 13","code.Code_INTERNAL.String() returns the string identifier INTERNAL","code.Code_name maps enum integer 13 to string name INTERNAL","code.Code_value maps string name INTERNAL to enum integer 13","status.Status stores Code_INTERNAL as error code and retains status message"],"goal":"verify google.golang.org/genproto/googleapis/rpc/code.Code_INTERNAL 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_INTERNAL"]},"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/code.Code_INTERNAL"],"verifierAdapter":"golang@1"}
go.mod
module example.com/sample

go 1.26.6

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

require google.golang.org/protobuf v1.35.1 // indirect
go.sum
github.com/google/go-cmp v0.5.9 h1:O2Tfq5qg4qc4AmwVlvv0oLiVAGB7enBSJ2x2DqQFi38=
github.com/google/go-cmp v0.5.9/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY=
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.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/rpc/code"
	"google.golang.org/genproto/googleapis/rpc/status"
)

// IsInternalErrorCode checks if the provided code corresponds to Code_INTERNAL.
func IsInternalErrorCode(c code.Code) bool {
	return c == code.Code_INTERNAL
}

// GetCodeName returns the string representation of the given Code.
func GetCodeName(c code.Code) string {
	return c.String()
}

// CreateInternalStatus creates a gRPC Status protobuf message with Code_INTERNAL.
func CreateInternalStatus(message string) *status.Status {
	return &status.Status{
		Code:    int32(code.Code_INTERNAL),
		Message: message,
	}
}

// ResolveCodeByName maps an error code name string to its enum value.
func ResolveCodeByName(name string) (code.Code, bool) {
	val, ok := code.Code_value[name]
	if !ok {
		return code.Code_OK, false
	}
	return code.Code(val), true
}

func main() {
	c := code.Code_INTERNAL
	fmt.Printf("Code: %s (%d)\n", GetCodeName(c), int32(c))

	st := CreateInternalStatus("internal server failure")
	fmt.Printf("Status: code=%d, message=%s\n", st.GetCode(), st.GetMessage())
}
spec.json
{
  "schemaVersion": 1,
  "goal": "verify google.golang.org/genproto/googleapis/rpc/code.Code_INTERNAL 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_INTERNAL"
  ]
}
test/contract.go
package main

import (
	"fmt"
	"os"

	"google.golang.org/genproto/googleapis/rpc/code"
	"google.golang.org/genproto/googleapis/rpc/status"
)

func main() {
	// Assertion 1: code.Code_INTERNAL has integer value 13
	if int32(code.Code_INTERNAL) != 13 {
		fmt.Fprintf(os.Stderr, "FAIL: Code_INTERNAL value mismatch: got %d, want 13\n", int32(code.Code_INTERNAL))
		os.Exit(1)
	}

	// Assertion 2: code.Code_INTERNAL.String() returns "INTERNAL"
	if code.Code_INTERNAL.String() != "INTERNAL" {
		fmt.Fprintf(os.Stderr, "FAIL: Code_INTERNAL string mismatch: got %q, want %q\n", code.Code_INTERNAL.String(), "INTERNAL")
		os.Exit(1)
	}

	// Assertion 3: code.Code_name maps 13 to "INTERNAL"
	if name, exists := code.Code_name[int32(code.Code_INTERNAL)]; !exists || name != "INTERNAL" {
		fmt.Fprintf(os.Stderr, "FAIL: Code_name mapping failed: exists=%v, name=%q\n", exists, name)
		os.Exit(1)
	}

	// Assertion 4: code.Code_value maps "INTERNAL" to 13
	if val, exists := code.Code_value["INTERNAL"]; !exists || val != 13 {
		fmt.Fprintf(os.Stderr, "FAIL: Code_value mapping failed: exists=%v, val=%d\n", exists, val)
		os.Exit(1)
	}

	// Assertion 5: status.Status message stores Code_INTERNAL error code
	st := &status.Status{
		Code:    int32(code.Code_INTERNAL),
		Message: "internal system error",
	}
	if st.GetCode() != int32(code.Code_INTERNAL) {
		fmt.Fprintf(os.Stderr, "FAIL: status.GetCode() mismatch: got %d, want %d\n", st.GetCode(), int32(code.Code_INTERNAL))
		os.Exit(1)
	}
	if st.GetMessage() != "internal system error" {
		fmt.Fprintf(os.Stderr, "FAIL: status.GetMessage() mismatch: got %q\n", st.GetMessage())
		os.Exit(1)
	}

	fmt.Println("PASS: google.golang.org/genproto/googleapis/rpc/code contract passed")
}

Ursprungs-Seeder

anonym