CodeSampleX

Exemple

google.golang.org/genproto v0.0.0-20190911173649-1774047e7e51: date.Date

Échantillon vérifié pour golang google.golang.org/genproto v0.0.0-20190911173649-1774047e7e51: date.Date. Le contrat s'est exécuté sur go 1.26 · linux…

sha256:40cd1f1f52e2b2fab1c43a49b5b95f6b016678859b3b42b238ae129d276d64bc

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 debian/x64 · docker ed25519:c1973797be207ac4 PASS compile:SKIPPED · contract:PASS · load:PASS · resolve:PASS
CONTAINER_RUN · golang@1golang:1.26@sha256:e30143be198a…
2026-10-21

Cas

HOW
Objectif
verify google.golang.org/genproto/googleapis/type/date.Date in pkg:golang/google.golang.org/genproto@v0.0.0-20190911173649-1774047e7e51
Paquets
Symboles
  • google.golang.org/genproto/googleapis/type/date.Date
Créé
2026-10-21T06:16:18Z

Contrat

  1. date.Date{Year: 2024, Month: 2, Day: 29} returns 2024, 2, 29 from GetYear(), GetMonth(), and GetDay()
  2. date.Date{Year: 0, Month: 12, Day: 25} supports partial dates with zero year
  3. (*date.Date).Descriptor() returns non-empty descriptor bytes and Reset() zeros Year, Month, and Day
  4. (*date.Date)(nil) returns 0 from GetYear(), GetMonth(), and GetDay() without panicking

Fichiers

  • PROMPT.md
  • csx.json
  • go.mod
  • go.sum
  • spec.json
  • test/contract.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/type/date.Date in pkg:golang/google.golang.org/genproto@v0.0.0-20190911173649-1774047e7e51
Kind: HOW

Use EXACTLY these public packages and versions:
  - pkg:golang/google.golang.org/genproto@v0.0.0-20190911173649-1774047e7e51
Demonstrate these symbols/APIs:
  - google.golang.org/genproto/googleapis/type/date.Date

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:012e274d19be1a1b6ca431090793f83e61d8cedfdbe43ebe53f09ec49dfd398e","contract":["date.Date{Year: 2024, Month: 2, Day: 29} returns 2024, 2, 29 from GetYear(), GetMonth(), and GetDay()","date.Date{Year: 0, Month: 12, Day: 25} supports partial dates with zero year","(*date.Date).Descriptor() returns non-empty descriptor bytes and Reset() zeros Year, Month, and Day","(*date.Date)(nil) returns 0 from GetYear(), GetMonth(), and GetDay() without panicking"],"goal":"verify google.golang.org/genproto/googleapis/type/date.Date in pkg:golang/google.golang.org/genproto@v0.0.0-20190911173649-1774047e7e51","kind":"HOW","packages":["pkg:golang/google.golang.org/genproto@v0.0.0-20190911173649-1774047e7e51"],"schemaVersion":1,"symbols":["google.golang.org/genproto/googleapis/type/date.Date"]},"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@v0.0.0-20190911173649-1774047e7e51"],"schemaVersion":1,"subject":"pkg:golang/google.golang.org/genproto@v0.0.0-20190911173649-1774047e7e51","symbols":["google.golang.org/genproto/googleapis/type/date.Date"],"verifierAdapter":"golang@1"}
go.mod
module example.com/sample

go 1.20

require google.golang.org/genproto v0.0.0-20190911173649-1774047e7e51

require github.com/golang/protobuf v1.3.2 // indirect
go.sum
cloud.google.com/go v0.26.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMTw=
github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU=
github.com/client9/misspell v0.3.4/go.mod h1:qj6jICC3Q7zFZvVWo7KLAzC3yx5G7kyvSDkc90ppPyw=
github.com/golang/glog v0.0.0-20160126235308-23def4e6c14b/go.mod h1:SBH7ygxi8pfUlaOkMMuAQtPIUF8ecWP5IEl/CR7VP2Q=
github.com/golang/mock v1.1.1/go.mod h1:oTYuIxOrZwtPieC+H1uAHpcLFnEyAGVDL/k47Jfbm0A=
github.com/golang/protobuf v1.2.0/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U=
github.com/golang/protobuf v1.3.2 h1:6nsPYzhq5kReh6QImI3k5qWzO4PEbvbIW2cwSfR/6xs=
github.com/golang/protobuf v1.3.2/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U=
golang.org/x/exp v0.0.0-20190121172915-509febef88a4/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA=
golang.org/x/lint v0.0.0-20181026193005-c67002cb31c3/go.mod h1:UVdnD1Gm6xHRNCYTkRU2/jEulfH38KcIWyp/GAMgvoE=
golang.org/x/lint v0.0.0-20190227174305-5b3e6a55c961/go.mod h1:wehouNa3lNwaWXcvxsM5YxQ5yQlVC4a0KAMCusXpPoU=
golang.org/x/net v0.0.0-20180724234803-3673e40ba225/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
golang.org/x/net v0.0.0-20180826012351-8a410e7b638d/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
golang.org/x/net v0.0.0-20190213061140-3a22650c66bd/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U=
golang.org/x/sync v0.0.0-20180314180146-1d60e4601c6f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sync v0.0.0-20181108010431-42b317875d0f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sys v0.0.0-20180830151530-49385e6e1522/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
golang.org/x/tools v0.0.0-20190114222345-bf090417da8b/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
golang.org/x/tools v0.0.0-20190226205152-f727befe758c/go.mod h1:9Yl7xja0Znq3iFh3HoIrodX9oNMXvdceNzlUR8zjMvY=
google.golang.org/appengine v1.1.0/go.mod h1:EbEs0AVv82hx2wNQdGPgUI5lhzA/G0D9YwlJXL52JkM=
google.golang.org/appengine v1.4.0/go.mod h1:xpcJRLb0r/rnEns0DIKYYv+WjYCduHsrkT7/EB5XEv4=
google.golang.org/genproto v0.0.0-20180817151627-c66870c02cf8/go.mod h1:JiN7NxoALGmiZfu7CAH4rXhgtRTLTxftemlI0sWmxmc=
google.golang.org/genproto v0.0.0-20190911173649-1774047e7e51 h1:Ex1mq5jaJof+kRnYi3SlYJ8KKa9Ao3NHyIT5XJ1gF6U=
google.golang.org/genproto v0.0.0-20190911173649-1774047e7e51/go.mod h1:IbNlFCBrqXvoKpeg0TB2l7cyZUmoaFKYIwrEpbDKLA8=
google.golang.org/grpc v1.19.0/go.mod h1:mqu4LbDTu4XGKhr4mRzUsmM4RtVoemTSY81AxZiDr8c=
honnef.co/go/tools v0.0.0-20190102054323-c2f93a96b099/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4=
spec.json
{
  "schemaVersion": 1,
  "goal": "verify google.golang.org/genproto/googleapis/type/date.Date in pkg:golang/google.golang.org/genproto@v0.0.0-20190911173649-1774047e7e51",
  "kind": "HOW",
  "packages": [
    "pkg:golang/google.golang.org/genproto@v0.0.0-20190911173649-1774047e7e51"
  ],
  "symbols": [
    "google.golang.org/genproto/googleapis/type/date.Date"
  ]
}
test/contract.go
package main

import (
	"fmt"
	"os"
	"strings"

	"google.golang.org/genproto/googleapis/type/date"
)

func main() {
	full := &date.Date{
		Year:  2024,
		Month: 2,
		Day:   29,
	}
	if full.GetYear() != 2024 || full.GetMonth() != 2 || full.GetDay() != 29 {
		fmt.Fprintf(os.Stderr, "unexpected full date values: %v\n", full)
		os.Exit(1)
	}
	s := full.String()
	if !strings.Contains(s, "year:2024") || !strings.Contains(s, "month:2") || !strings.Contains(s, "day:29") {
		fmt.Fprintf(os.Stderr, "unexpected string representation: %q\n", s)
		os.Exit(1)
	}

	desc, idx := full.Descriptor()
	if len(desc) == 0 || len(idx) != 1 || idx[0] != 0 {
		fmt.Fprintf(os.Stderr, "unexpected descriptor: len(desc)=%d, idx=%v\n", len(desc), idx)
		os.Exit(1)
	}

	partial := &date.Date{
		Year:  0,
		Month: 12,
		Day:   25,
	}
	if partial.GetYear() != 0 || partial.GetMonth() != 12 || partial.GetDay() != 25 {
		fmt.Fprintf(os.Stderr, "unexpected partial date values: %v\n", partial)
		os.Exit(1)
	}

	full.Reset()
	if full.GetYear() != 0 || full.GetMonth() != 0 || full.GetDay() != 0 {
		fmt.Fprintf(os.Stderr, "expected Reset() to clear fields, got: %v\n", full)
		os.Exit(1)
	}

	var nilDate *date.Date
	if nilDate.GetYear() != 0 || nilDate.GetMonth() != 0 || nilDate.GetDay() != 0 {
		fmt.Fprintln(os.Stderr, "expected nil receiver getters to return 0")
		os.Exit(1)
	}
}

Seeder d'origine

anonyme