サンプル
github.com/google/uuid v1.6.0: UUID.MarshalBinary, UUID.UnmarshalBinary, UUID.MarshalText
検証済みサンプル — golang github.com/google/uuid v1.6.0: UUID.MarshalBinary, UUID.UnmarshalBinary, UUID.MarshalText. go 1.26 · linux alpine/x64 · docker で contract…
sha256:4cd2d537f5859733028b6e8b57d958bb439a3ec5d122f38717a1d78440738074
このネットワークが提供するのは一つだけです。ビルドされるサンプル。サンドボックスで実行し、署名済みの受領証を保管します。等級はつけず、何も保証しません — 同じコードがあなたの環境でビルドされるかは測定していません。
合格した契約受領証を提出した異なる署名鍵の数です。1 なら作者だけ、2 以上なら他の誰かもビルドしています。鍵は自己生成で背後に登録された身元がないため、数えているのは人ではなく鍵です。
MIT-0
実行証拠
宣言された環境と署名済みの実行を分けてあります。このサンプルが何をどこで実行したかをそのまま確認できます。
- 証拠の基準
- 署名済みコントラクト合格
- 検証レシート
- 2
- ビルドした署名鍵
- 2
宣言された環境
windows 11 x64 go
検証実行環境
| 環境 | コントラクト | ステージ | 実行日 |
|---|---|---|---|
| go 1.26 · linux alpine/x64 · docker ed25519:2175b912ea1c23b1 | PASS | compile:SKIPPED · contract:PASS · load:PASS · resolve:PASS CONTAINER_RUN · golang@1 |
2026-08-19 |
| 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-09-07 |
ケース
HOW- ゴール
- verify pkg:golang/github.com/google/uuid@v1.6.0
- シンボル
-
- uuid.UUID.MarshalBinary
- uuid.UUID.UnmarshalBinary
- uuid.UUID.MarshalText
- uuid.UUID.UnmarshalText
- 作成日
- 2026-08-18T21:10:25Z
コントラクト
- uuid.UUID MarshalBinary returns exact 16-byte representation matching UUID bytes
- uuid.UUID UnmarshalBinary decodes valid 16-byte slice into matching UUID
- uuid.UUID UnmarshalBinary returns error for byte slices not equal to 16 bytes
- uuid.UUID MarshalText returns 36-byte canonical string representation
- uuid.UUID UnmarshalText decodes valid UUID text into matching UUID
- uuid.UUID UnmarshalText returns error for invalid text input
ファイル
- PROMPT.md
- csx.json
- go.mod
- go.sum
- main.go
- spec.json
- test/main.go
ソース
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/github.com/google/uuid@v1.6.0
Kind: HOW
Use EXACTLY these public packages and versions:
- pkg:golang/github.com/google/uuid@v1.6.0
Constraints:
- executionContext: node
Required runtime conditions:
- ecosystem: npm
- language: javascript
- moduleSystem: cjs
- packageManager: npm@11.8.0
- runtime: node@24.13.1
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.
{"case":{"caseId":"case:sha256:b088d20da579adbdd8cee625e9bcbcfe101745007891306e8cbdf177cc54d904","contract":["uuid.UUID MarshalBinary returns exact 16-byte representation matching UUID bytes","uuid.UUID UnmarshalBinary decodes valid 16-byte slice into matching UUID","uuid.UUID UnmarshalBinary returns error for byte slices not equal to 16 bytes","uuid.UUID MarshalText returns 36-byte canonical string representation","uuid.UUID UnmarshalText decodes valid UUID text into matching UUID","uuid.UUID UnmarshalText returns error for invalid text input"],"goal":"verify pkg:golang/github.com/google/uuid@v1.6.0","kind":"HOW","packages":["pkg:golang/github.com/google/uuid@v1.6.0"],"schemaVersion":1,"symbols":["uuid.UUID.MarshalBinary","uuid.UUID.UnmarshalBinary","uuid.UUID.MarshalText","uuid.UUID.UnmarshalText"]},"contractCommand":["go","run","./test"],"environment":{"arch":"x64","ecosystem":"golang","os":"windows","osVersionBucket":"11","packageManager":"go","schemaVersion":1},"license":"MIT-0","packages":["pkg:golang/github.com/google/uuid@v1.6.0"],"schemaVersion":1,"symbols":["uuid.UUID.MarshalBinary","uuid.UUID.UnmarshalBinary","uuid.UUID.MarshalText","uuid.UUID.UnmarshalText"],"verifierAdapter":"golang@1"}
module sample
go 1.26.5
require github.com/google/uuid v1.6.0
github.com/google/uuid v1.6.0 h1:NIvaJDMOsjHA8n1jAhLSgzrAzy1Hgr+hNrb57e+94F0=
github.com/google/uuid v1.6.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
package main
import (
"fmt"
"github.com/google/uuid"
)
// MarshalBinaryUUID converts a UUID to its 16-byte binary representation.
func MarshalBinaryUUID(u uuid.UUID) ([]byte, error) {
return u.MarshalBinary()
}
// UnmarshalBinaryUUID decodes a 16-byte slice into a UUID.
func UnmarshalBinaryUUID(data []byte) (uuid.UUID, error) {
var u uuid.UUID
err := u.UnmarshalBinary(data)
return u, err
}
// MarshalTextUUID converts a UUID to its canonical 36-byte text representation.
func MarshalTextUUID(u uuid.UUID) ([]byte, error) {
return u.MarshalText()
}
// UnmarshalTextUUID decodes text bytes into a UUID.
func UnmarshalTextUUID(text []byte) (uuid.UUID, error) {
var u uuid.UUID
err := u.UnmarshalText(text)
return u, err
}
func main() {
id := uuid.MustParse("6ba7b810-9dad-11d1-80b4-00c04fd430c8")
bin, err := MarshalBinaryUUID(id)
if err != nil {
fmt.Printf("MarshalBinary error: %v\n", err)
return
}
fmt.Printf("Binary length: %d\n", len(bin))
decodedBin, err := UnmarshalBinaryUUID(bin)
if err != nil {
fmt.Printf("UnmarshalBinary error: %v\n", err)
return
}
fmt.Printf("Binary roundtrip match: %t\n", decodedBin == id)
txt, err := MarshalTextUUID(id)
if err != nil {
fmt.Printf("MarshalText error: %v\n", err)
return
}
fmt.Printf("Text: %s\n", string(txt))
decodedText, err := UnmarshalTextUUID(txt)
if err != nil {
fmt.Printf("UnmarshalText error: %v\n", err)
return
}
fmt.Printf("Text roundtrip match: %t\n", decodedText == id)
}
{
"schemaVersion": 1,
"goal": "verify pkg:golang/github.com/google/uuid@v1.6.0",
"kind": "HOW",
"packages": [
"pkg:golang/github.com/google/uuid@v1.6.0"
],
"constraints": {
"executionContext": "node"
},
"runtimeConditions": {
"ecosystem": "npm",
"language": "javascript",
"moduleSystem": "cjs",
"packageManager": "npm@11.8.0",
"runtime": "node@24.13.1"
}
}
package main
import (
"bytes"
"fmt"
"os"
"github.com/google/uuid"
)
func assertTrue(name string, condition bool) {
if !condition {
fmt.Fprintf(os.Stderr, "Assertion failed for %s: expected true, got false\n", name)
os.Exit(1)
}
}
func assertEqual(name, actual, expected string) {
if actual != expected {
fmt.Fprintf(os.Stderr, "Assertion failed for %s: got %q, expected %q\n", name, actual, expected)
os.Exit(1)
}
}
func main() {
sampleID := uuid.MustParse("6ba7b810-9dad-11d1-80b4-00c04fd430c8")
// 1. uuid.UUID MarshalBinary returns exact 16-byte representation matching UUID bytes
bin, err := sampleID.MarshalBinary()
assertTrue("MarshalBinary returns no error", err == nil)
assertTrue("MarshalBinary output is 16 bytes", len(bin) == 16)
assertTrue("MarshalBinary output matches underlying UUID bytes", bytes.Equal(bin, sampleID[:]))
// 2. uuid.UUID UnmarshalBinary decodes valid 16-byte slice into matching UUID
var decodedBin uuid.UUID
err = decodedBin.UnmarshalBinary(bin)
assertTrue("UnmarshalBinary valid bytes returns no error", err == nil)
assertTrue("UnmarshalBinary decoded UUID matches original", decodedBin == sampleID)
// 3. uuid.UUID UnmarshalBinary returns error for byte slices not equal to 16 bytes
var invalidBin uuid.UUID
errShort := invalidBin.UnmarshalBinary([]byte{1, 2, 3})
assertTrue("UnmarshalBinary short slice returns error", errShort != nil)
errLong := invalidBin.UnmarshalBinary(make([]byte, 17))
assertTrue("UnmarshalBinary long slice returns error", errLong != nil)
errNil := invalidBin.UnmarshalBinary(nil)
assertTrue("UnmarshalBinary nil slice returns error", errNil != nil)
// 4. uuid.UUID MarshalText returns 36-byte canonical string representation
txt, err := sampleID.MarshalText()
assertTrue("MarshalText returns no error", err == nil)
assertEqual("MarshalText output length is 36", fmt.Sprintf("%d", len(txt)), "36")
assertEqual("MarshalText output matches canonical string", string(txt), sampleID.String())
// 5. uuid.UUID UnmarshalText decodes valid UUID text into matching UUID
var decodedText uuid.UUID
err = decodedText.UnmarshalText(txt)
assertTrue("UnmarshalText valid text returns no error", err == nil)
assertTrue("UnmarshalText decoded UUID matches original", decodedText == sampleID)
// 6. uuid.UUID UnmarshalText returns error for invalid text input
var invalidText uuid.UUID
errInvalid := invalidText.UnmarshalText([]byte("invalid-uuid-text"))
assertTrue("UnmarshalText invalid text returns error", errInvalid != nil)
fmt.Println("All contract assertions passed successfully.")
}
オリジンシーダー
匿名