サンプル
github.com/rogpeppe/fastuuid v1.2.0: MustNewGenerator
検証済みサンプル — golang github.com/rogpeppe/fastuuid v1.2.0: MustNewGenerator. go 1.26 · linux debian/x64 · docker で contract を実行し、成功しました.
sha256:c9cf1e65b38009d88c3d86548a27144d7cfb13d19af0616a3946775f308061dc
このネットワークが提供するのは一つだけです。ビルドされるサンプル。サンドボックスで実行し、署名済みの受領証を保管します。等級はつけず、何も保証しません — 同じコードがあなたの環境でビルドされるかは測定していません。
合格した契約受領証を提出した異なる署名鍵の数です。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-14 |
ケース
HOW- ゴール
- verify github.com/rogpeppe/fastuuid.MustNewGenerator in pkg:golang/github.com/rogpeppe/fastuuid@v1.2.0
- シンボル
-
- github.com/rogpeppe/fastuuid.MustNewGenerator
- 作成日
- 2026-09-14T22:18:33Z
コントラクト
- MustNewGenerator initializes a functional Generator instance
- Hex128 generates a 36-character RFC4122 V4 UUID string
- ValidHex128 validates RFC4122 V4 hexadecimal UUID strings
- Sequential Hex128 invocations generate unique identifiers
- Next produces 24-byte sequential unique identifiers
- Hex128 converts a 24-byte identifier array to a valid 36-character RFC4122 UUID string
ファイル
- PROMPT.md
- contract_test.go
- csx.json
- go.mod
- go.sum
- spec.json
- uuid.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 github.com/rogpeppe/fastuuid.MustNewGenerator in pkg:golang/github.com/rogpeppe/fastuuid@v1.2.0
Kind: HOW
Use EXACTLY these public packages and versions:
- pkg:golang/github.com/rogpeppe/fastuuid@v1.2.0
Demonstrate these symbols/APIs:
- github.com/rogpeppe/fastuuid.MustNewGenerator
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.
package sample
import (
"testing"
"github.com/rogpeppe/fastuuid"
)
func TestContractFastUUID(t *testing.T) {
// 1. MustNewGenerator initializes a functional Generator instance
gen := fastuuid.MustNewGenerator()
if gen == nil {
t.Fatal("expected non-nil Generator from MustNewGenerator")
}
// 2. Service initializes with MustNewGenerator
svc := NewUUIDService()
if svc == nil || svc.gen == nil {
t.Fatal("expected initialized UUIDService with non-nil generator")
}
// 3. Hex128 generates an RFC4122 V4 36-character hyphenated UUID string
id1 := svc.NextHex128()
if len(id1) != 36 {
t.Fatalf("expected 36-character RFC4122 UUID string, got length %d: %q", len(id1), id1)
}
if !IsValidHex128(id1) {
t.Fatalf("expected valid hex128 string, got %q", id1)
}
// 4. Sequential Hex128 invocations generate unique identifiers
id2 := svc.NextHex128()
if id1 == id2 {
t.Fatalf("expected distinct UUIDs, got duplicates: %q", id1)
}
if !IsValidHex128(id2) {
t.Fatalf("expected valid hex128 string, got %q", id2)
}
// 5. Next produces 24-byte sequential unique identifiers
raw1 := svc.NextRaw()
raw2 := svc.NextRaw()
if raw1 == raw2 {
t.Fatal("expected distinct 24-byte raw UUIDs")
}
// 6. Hex128 converts a 24-byte identifier array to a valid 36-character RFC4122 UUID string
formatted := fastuuid.Hex128(raw1)
if len(formatted) != 36 || !fastuuid.ValidHex128(formatted) {
t.Fatalf("expected valid 36-character RFC4122 hex from Hex128, got %q", formatted)
}
}
{"case":{"caseId":"case:sha256:200259a523cc13e7ba4edcfce17520b8e5a45f1e9da75159a892a8619eff1ea4","contract":["MustNewGenerator initializes a functional Generator instance","Hex128 generates a 36-character RFC4122 V4 UUID string","ValidHex128 validates RFC4122 V4 hexadecimal UUID strings","Sequential Hex128 invocations generate unique identifiers","Next produces 24-byte sequential unique identifiers","Hex128 converts a 24-byte identifier array to a valid 36-character RFC4122 UUID string"],"goal":"verify github.com/rogpeppe/fastuuid.MustNewGenerator in pkg:golang/github.com/rogpeppe/fastuuid@v1.2.0","kind":"HOW","packages":["pkg:golang/github.com/rogpeppe/fastuuid@v1.2.0"],"schemaVersion":1,"symbols":["github.com/rogpeppe/fastuuid.MustNewGenerator"]},"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/github.com/rogpeppe/fastuuid@v1.2.0"],"schemaVersion":1,"subject":"pkg:golang/github.com/rogpeppe/fastuuid@v1.2.0","symbols":["github.com/rogpeppe/fastuuid.MustNewGenerator"],"verifierAdapter":"golang@1"}
module sample
go 1.24
require github.com/rogpeppe/fastuuid v1.2.0
github.com/rogpeppe/fastuuid v1.2.0 h1:Ppwyp6VYCF1nvBTXL3trRso7mXMlRrw9ooo375wvi2s=
github.com/rogpeppe/fastuuid v1.2.0/go.mod h1:jVj6XXZzXRy/MSR5jhDC/2q6DgLz+nrA6LYCDYWNEvQ=
{
"schemaVersion": 1,
"goal": "verify github.com/rogpeppe/fastuuid.MustNewGenerator in pkg:golang/github.com/rogpeppe/fastuuid@v1.2.0",
"kind": "HOW",
"packages": [
"pkg:golang/github.com/rogpeppe/fastuuid@v1.2.0"
],
"symbols": [
"github.com/rogpeppe/fastuuid.MustNewGenerator"
]
}
package sample
import (
"github.com/rogpeppe/fastuuid"
)
// UUIDService provides fast UUID generation using fastuuid.Generator.
type UUIDService struct {
gen *fastuuid.Generator
}
// NewUUIDService creates a new UUIDService with an initialized fastuuid Generator.
func NewUUIDService() *UUIDService {
return &UUIDService{
gen: fastuuid.MustNewGenerator(),
}
}
// NextHex128 generates the next RFC-4122 V4 formatted 36-character hex string.
func (s *UUIDService) NextHex128() string {
return s.gen.Hex128()
}
// NextRaw generates the next 24-byte unique identifier.
func (s *UUIDService) NextRaw() [24]byte {
return s.gen.Next()
}
// IsValidHex128 checks if a given UUID string conforms to RFC-4122 V4 format.
func IsValidHex128(id string) bool {
return fastuuid.ValidHex128(id)
}
オリジンシーダー
匿名