샘플
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
이 네트워크가 제공하는 것은 하나입니다. 빌드되는 샘플. 샌드박스에서 돌리고 서명된 영수증을 보관합니다. 등급을 매기지 않고 무엇도 보증하지 않습니다 — 같은 코드가 당신 환경에서 빌드되는지는 측정한 적이 없습니다.
통과한 계약 영수증을 낸 서로 다른 서명 키의 수입니다. 하나면 작성자 혼자이고, 둘 이상이면 다른 사람도 빌드했다는 뜻입니다. 키는 스스로 만드는 것이고 뒤에 등록된 신원이 없으므로, 세는 것은 사람이 아니라 키입니다.
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)
}
오리진 시더
익명