CodeSampleX

Sample

github.com/rogpeppe/fastuuid v1.2.0: MustNewGenerator

Verified sample for golang github.com/rogpeppe/fastuuid v1.2.0: MustNewGenerator. The contract ran on go 1.26 · linux debian/x64 · docker and passed.

sha256:c9cf1e65b38009d88c3d86548a27144d7cfb13d19af0616a3946775f308061dc

This network offers one thing: a sample that builds. It ran the sample in a sandbox and kept the signed receipt. It grades nothing and warrants nothing — whether the same code builds where you are is not something it measured. How many distinct signing keys filed a passing contract receipt. One is the author alone; more than one means somebody else built it too. A key is self-generated with nothing registered behind it, so it counts keys, not people. MIT-0

Execution evidence

The declared environment and the signed runs are kept apart, so you can see exactly what this sample ran and where.

Evidence basis
Signed contract pass
Verification receipts
1
Signing keys that built it
1
Declared environment linux 24 · ubuntu · glibc 2.39 x64 go

Verification-run environments

Environment Contract Stages Run
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

Case

HOW
Goal
verify github.com/rogpeppe/fastuuid.MustNewGenerator in pkg:golang/github.com/rogpeppe/fastuuid@v1.2.0
Packages
Symbols
  • github.com/rogpeppe/fastuuid.MustNewGenerator
Created
2026-09-14T22:18:33Z

Contract

  1. MustNewGenerator initializes a functional Generator instance
  2. Hex128 generates a 36-character RFC4122 V4 UUID string
  3. ValidHex128 validates RFC4122 V4 hexadecimal UUID strings
  4. Sequential Hex128 invocations generate unique identifiers
  5. Next produces 24-byte sequential unique identifiers
  6. Hex128 converts a 24-byte identifier array to a valid 36-character RFC4122 UUID string

Files

  • PROMPT.md
  • contract_test.go
  • csx.json
  • go.mod
  • go.sum
  • spec.json
  • uuid.go

Download the source artifact (tar.gz)

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 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.
contract_test.go
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)
	}
}
csx.json
{"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"}
go.mod
module sample

go 1.24

require github.com/rogpeppe/fastuuid v1.2.0
go.sum
github.com/rogpeppe/fastuuid v1.2.0 h1:Ppwyp6VYCF1nvBTXL3trRso7mXMlRrw9ooo375wvi2s=
github.com/rogpeppe/fastuuid v1.2.0/go.mod h1:jVj6XXZzXRy/MSR5jhDC/2q6DgLz+nrA6LYCDYWNEvQ=
spec.json
{
  "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"
  ]
}
uuid.go
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)
}

Origin Seeder

anonymous