CodeSampleX

サンプル

google.golang.org/genproto v0.0.0-20190306203927-b5d61aea6440

検証済みサンプル — golang google.golang.org/genproto v0.0.0-20190306203927-b5d61aea6440. go 1.26 · linux debian/x64 · docker で contract を実行し、成功しました.

sha256:d0ced9745b2f2a419cf85d45f89478b27ae5f5256ee0a0c646d11a5a276490be

このネットワークが提供するのは一つだけです。ビルドされるサンプル。サンドボックスで実行し、署名済みの受領証を保管します。等級はつけず、何も保証しません — 同じコードがあなたの環境でビルドされるかは測定していません。 合格した契約受領証を提出した異なる署名鍵の数です。1 なら作者だけ、2 以上なら他の誰かもビルドしています。鍵は自己生成で背後に登録された身元がないため、数えているのは人ではなく鍵です。 MIT-0

実行証拠

宣言された環境と署名済みの実行を分けてあります。このサンプルが何をどこで実行したかをそのまま確認できます。

証拠の基準
署名済みコントラクト合格
検証レシート
1
ビルドした署名鍵
1
宣言された環境 linux 24 · ubuntu · glibc 2.39 x64 go

検証実行環境

環境 コントラクト ステージ 実行日
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-09-19

ケース

HOW
ゴール
verify pkg:golang/google.golang.org/genproto@v0.0.0-20190306203927-b5d61aea6440
パッケージ
作成日
2026-09-18T15:36:15Z

コントラクト

  1. date.Date.GetYear, GetMonth, and GetDay return zero values on nil or uninitialized instances, and return set values on populated instances.
  2. latlng.LatLng.GetLatitude and GetLongitude return 0.0 on nil instances, and return configured coordinates on populated instances.
  3. date.Date serializes to protobuf bytes and unmarshals back preserving year, month, and day.
  4. latlng.LatLng serializes to protobuf bytes and unmarshals back preserving latitude and longitude coordinates.
  5. date.Date.Reset clears all fields restoring the instance to its zero state.
  6. latlng.LatLng.Reset clears latitude and longitude restoring the instance to its zero state.

ファイル

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

ソースアーティファクトをダウンロード (tar.gz)

ソース

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 pkg:golang/google.golang.org/genproto@v0.0.0-20190306203927-b5d61aea6440
Kind: HOW

Use EXACTLY these public packages and versions:
  - pkg:golang/google.golang.org/genproto@v0.0.0-20190306203927-b5d61aea6440

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:7ae0afa6820b9901b19cbc266e01764b91da24fd6c05ef95a743d01c1bd1559d","contract":["date.Date.GetYear, GetMonth, and GetDay return zero values on nil or uninitialized instances, and return set values on populated instances.","latlng.LatLng.GetLatitude and GetLongitude return 0.0 on nil instances, and return configured coordinates on populated instances.","date.Date serializes to protobuf bytes and unmarshals back preserving year, month, and day.","latlng.LatLng serializes to protobuf bytes and unmarshals back preserving latitude and longitude coordinates.","date.Date.Reset clears all fields restoring the instance to its zero state.","latlng.LatLng.Reset clears latitude and longitude restoring the instance to its zero state."],"goal":"verify pkg:golang/google.golang.org/genproto@v0.0.0-20190306203927-b5d61aea6440","kind":"HOW","packages":["pkg:golang/google.golang.org/genproto@v0.0.0-20190306203927-b5d61aea6440"],"schemaVersion":1},"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-20190306203927-b5d61aea6440"],"schemaVersion":1,"subject":"pkg:golang/google.golang.org/genproto@v0.0.0-20190306203927-b5d61aea6440","verifierAdapter":"golang@1"}
go.mod
module example.com/verify

go 1.26.6

require (
	github.com/golang/protobuf v1.2.0
	google.golang.org/genproto v0.0.0-20190306203927-b5d61aea6440
)
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 h1:P3YflyNX/ehuJFLhxviNdFxQPkGK5cDcApsge1SqnvM=
github.com/golang/protobuf v1.2.0/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/sync v0.0.0-20190227155943-e225da77a7e6 h1:bjcUS9ztw9kFmmIxJInhon/0Is3p+EHBKNgquIzo1OI=
golang.org/x/sync v0.0.0-20190227155943-e225da77a7e6/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-20190306203927-b5d61aea6440 h1:VOR2wHHZJgoALLvnlCN4JUaWACO1lOLXiSN2F3g/GXU=
google.golang.org/genproto v0.0.0-20190306203927-b5d61aea6440/go.mod h1:VzzqZJRnGkLBvHegQrXjBqPurQTc5/KpmUdxsrq26oE=
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=
main.go
package main

import (
	"fmt"

	"github.com/golang/protobuf/proto"
	"google.golang.org/genproto/googleapis/type/date"
	"google.golang.org/genproto/googleapis/type/latlng"
)

func main() {
	d := &date.Date{
		Year:  2026,
		Month: 9,
		Day:   18,
	}
	fmt.Printf("Date: %04d-%02d-%02d\n", d.GetYear(), d.GetMonth(), d.GetDay())

	loc := &latlng.LatLng{
		Latitude:  37.422,
		Longitude: -122.084,
	}
	fmt.Printf("Location: lat=%f, lng=%f\n", loc.GetLatitude(), loc.GetLongitude())

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

	var decoded date.Date
	if err := proto.Unmarshal(data, &decoded); err != nil {
		panic(err)
	}
	fmt.Printf("Decoded date: %04d-%02d-%02d\n", decoded.GetYear(), decoded.GetMonth(), decoded.GetDay())
}
spec.json
{
  "schemaVersion": 1,
  "goal": "verify pkg:golang/google.golang.org/genproto@v0.0.0-20190306203927-b5d61aea6440",
  "kind": "HOW",
  "packages": [
    "pkg:golang/google.golang.org/genproto@v0.0.0-20190306203927-b5d61aea6440"
  ]
}
test/contract.go
package main

import (
	"fmt"
	"math"
	"os"

	"github.com/golang/protobuf/proto"
	"google.golang.org/genproto/googleapis/type/date"
	"google.golang.org/genproto/googleapis/type/latlng"
)

func main() {
	// Assertion 1: date.Date.GetYear, GetMonth, and GetDay return zero values on nil or uninitialized instances, and return set values on populated instances.
	{
		var nilDate *date.Date
		if nilDate.GetYear() != 0 || nilDate.GetMonth() != 0 || nilDate.GetDay() != 0 {
			fmt.Fprintf(os.Stderr, "assertion 1 failed: nil date getters must return 0\n")
			os.Exit(1)
		}

		emptyDate := &date.Date{}
		if emptyDate.GetYear() != 0 || emptyDate.GetMonth() != 0 || emptyDate.GetDay() != 0 {
			fmt.Fprintf(os.Stderr, "assertion 1 failed: empty date getters must return 0\n")
			os.Exit(1)
		}

		d := &date.Date{Year: 2026, Month: 9, Day: 18}
		if d.GetYear() != 2026 || d.GetMonth() != 9 || d.GetDay() != 18 {
			fmt.Fprintf(os.Stderr, "assertion 1 failed: populated date getters mismatch\n")
			os.Exit(1)
		}
	}

	// Assertion 2: latlng.LatLng.GetLatitude and GetLongitude return 0.0 on nil instances, and return configured coordinates on populated instances.
	{
		var nilLatLng *latlng.LatLng
		if nilLatLng.GetLatitude() != 0.0 || nilLatLng.GetLongitude() != 0.0 {
			fmt.Fprintf(os.Stderr, "assertion 2 failed: nil latlng getters must return 0.0\n")
			os.Exit(1)
		}

		emptyLatLng := &latlng.LatLng{}
		if emptyLatLng.GetLatitude() != 0.0 || emptyLatLng.GetLongitude() != 0.0 {
			fmt.Fprintf(os.Stderr, "assertion 2 failed: empty latlng getters must return 0.0\n")
			os.Exit(1)
		}

		pos := &latlng.LatLng{Latitude: 37.422, Longitude: -122.084}
		if math.Abs(pos.GetLatitude()-37.422) > 1e-6 || math.Abs(pos.GetLongitude()-(-122.084)) > 1e-6 {
			fmt.Fprintf(os.Stderr, "assertion 2 failed: populated latlng getters mismatch\n")
			os.Exit(1)
		}
	}

	// Assertion 3: date.Date serializes to protobuf bytes and unmarshals back preserving year, month, and day.
	{
		orig := &date.Date{Year: 2019, Month: 3, Day: 6}
		data, err := proto.Marshal(orig)
		if err != nil {
			fmt.Fprintf(os.Stderr, "assertion 3 failed: marshal failed: %v\n", err)
			os.Exit(1)
		}
		if len(data) == 0 {
			fmt.Fprintf(os.Stderr, "assertion 3 failed: marshal returned empty bytes\n")
			os.Exit(1)
		}

		var decoded date.Date
		if err := proto.Unmarshal(data, &decoded); err != nil {
			fmt.Fprintf(os.Stderr, "assertion 3 failed: unmarshal failed: %v\n", err)
			os.Exit(1)
		}
		if decoded.GetYear() != 2019 || decoded.GetMonth() != 3 || decoded.GetDay() != 6 {
			fmt.Fprintf(os.Stderr, "assertion 3 failed: unmarshaled values mismatch\n")
			os.Exit(1)
		}
	}

	// Assertion 4: latlng.LatLng serializes to protobuf bytes and unmarshals back preserving latitude and longitude coordinates.
	{
		orig := &latlng.LatLng{Latitude: -33.8688, Longitude: 151.2093}
		data, err := proto.Marshal(orig)
		if err != nil {
			fmt.Fprintf(os.Stderr, "assertion 4 failed: marshal failed: %v\n", err)
			os.Exit(1)
		}
		if len(data) == 0 {
			fmt.Fprintf(os.Stderr, "assertion 4 failed: marshal returned empty bytes\n")
			os.Exit(1)
		}

		var decoded latlng.LatLng
		if err := proto.Unmarshal(data, &decoded); err != nil {
			fmt.Fprintf(os.Stderr, "assertion 4 failed: unmarshal failed: %v\n", err)
			os.Exit(1)
		}
		if math.Abs(decoded.GetLatitude()-orig.Latitude) > 1e-6 || math.Abs(decoded.GetLongitude()-orig.Longitude) > 1e-6 {
			fmt.Fprintf(os.Stderr, "assertion 4 failed: unmarshaled coordinates mismatch\n")
			os.Exit(1)
		}
	}

	// Assertion 5: date.Date.Reset clears all fields restoring the instance to its zero state.
	{
		d := &date.Date{Year: 2024, Month: 12, Day: 25}
		d.Reset()
		if d.GetYear() != 0 || d.GetMonth() != 0 || d.GetDay() != 0 {
			fmt.Fprintf(os.Stderr, "assertion 5 failed: Reset did not clear date fields\n")
			os.Exit(1)
		}
	}

	// Assertion 6: latlng.LatLng.Reset clears latitude and longitude restoring the instance to its zero state.
	{
		pos := &latlng.LatLng{Latitude: 48.8566, Longitude: 2.3522}
		pos.Reset()
		if pos.GetLatitude() != 0.0 || pos.GetLongitude() != 0.0 {
			fmt.Fprintf(os.Stderr, "assertion 6 failed: Reset did not clear latlng fields\n")
			os.Exit(1)
		}
	}

	fmt.Println("All contract assertions passed.")
}

オリジンシーダー

匿名