Beispiel
github.com/google/uuid v1.6.0: generate and parse UUID v4 using google uuid
Verifiziertes Beispiel für golang github.com/google/uuid v1.6.0: generate and parse UUID v4 using google uuid. Der Vertrag lief auf go 1.26 · linux…
sha256:e8dbd063bf27ad16bbeaaef62313041501d6c7442f75262f8e51cd2b4a58dae4
Dieses Netzwerk bietet eine Sache: ein Sample, das baut. Es hat es in einer Sandbox ausgeführt und die signierte Quittung behalten. Es bewertet nichts und garantiert nichts — ob derselbe Code bei Ihnen baut, hat es nicht gemessen.
Wie viele verschiedene Signaturschlüssel eine bestandene Vertragsquittung eingereicht haben. Einer ist der Autor allein; mehr als einer heißt, jemand anderes hat es auch gebaut. Ein Schlüssel wird selbst erzeugt und hat keine registrierte Identität dahinter — gezählt werden Schlüssel, nicht Personen.
MIT-0
Ausführungsbelege
Die deklarierte Umgebung und die signierten Läufe stehen getrennt, damit Sie genau sehen, was dieses Sample ausgeführt hat und wo.
- Beleggrundlage
- Signierter Vertrag bestanden
- Verifizierungsbelege
- 2
- Signaturschlüssel, die es gebaut haben
- 2
Deklarierte Umgebung
windows 11 x64 go
Umgebungen der Verifizierungsläufe
| Umgebung | Contract | Stufen | Lauf |
|---|---|---|---|
| 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 |
Fall
HOW- Ziel
- generate and parse UUID v4 using google uuid
- Symbole
-
- github.com/google/uuid.NewRandom
- github.com/google/uuid.Parse
- Erstellt
- 2026-08-19T04:23:04Z
Contract
- uuid.NewRandom generates a random version 4 UUID with RFC4122 variant and nil error
- uuid.Parse parses a valid UUID string representation back to the matching UUID value
- uuid.Parse returns a non-nil error when given an invalid UUID string
Dateien
- PROMPT.md
- csx.json
- go.mod
- go.sum
- sample.go
- spec.json
- test/contract.go
Quelltext
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: generate and parse UUID v4 using google uuid
Kind: HOW
Use EXACTLY these public packages and versions:
- pkg:golang/github.com/google/uuid@v1.6.0
Demonstrate these symbols/APIs:
- github.com/google/uuid.NewRandom
- github.com/google/uuid.Parse
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:10b002aa9a61d0f74b260f093b3831c8bd7cd6b3ce8f8f9966ba77a4bdc6af09","contract":["uuid.NewRandom generates a random version 4 UUID with RFC4122 variant and nil error","uuid.Parse parses a valid UUID string representation back to the matching UUID value","uuid.Parse returns a non-nil error when given an invalid UUID string"],"goal":"generate and parse UUID v4 using google uuid","kind":"HOW","packages":["pkg:golang/github.com/google/uuid@v1.6.0"],"schemaVersion":1,"symbols":["github.com/google/uuid.NewRandom","github.com/google/uuid.Parse"]},"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":["github.com/google/uuid.NewRandom","github.com/google/uuid.Parse"],"verifierAdapter":"golang@1"}
module sample
go 1.22.0
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 sample
import (
"fmt"
"github.com/google/uuid"
)
// GenerateRandomUUID creates a new random (v4) UUID.
func GenerateRandomUUID() (uuid.UUID, error) {
u, err := uuid.NewRandom()
if err != nil {
return uuid.Nil, fmt.Errorf("generate random uuid: %w", err)
}
return u, nil
}
// ParseUUID parses a standard 36-character string representation of a UUID.
func ParseUUID(s string) (uuid.UUID, error) {
u, err := uuid.Parse(s)
if err != nil {
return uuid.Nil, fmt.Errorf("parse uuid: %w", err)
}
return u, nil
}
{
"schemaVersion": 1,
"goal": "generate and parse UUID v4 using google uuid",
"kind": "HOW",
"packages": [
"pkg:golang/github.com/google/uuid@v1.6.0"
],
"symbols": [
"github.com/google/uuid.NewRandom",
"github.com/google/uuid.Parse"
]
}
package main
import (
"fmt"
"os"
"github.com/google/uuid"
"sample"
)
func main() {
// 1. Assert uuid.NewRandom generates a valid UUID v4
u, err := uuid.NewRandom()
if err != nil {
fmt.Fprintf(os.Stderr, "uuid.NewRandom failed: %v\n", err)
os.Exit(1)
}
if u.Version() != 4 {
fmt.Fprintf(os.Stderr, "expected UUID version 4, got %d\n", u.Version())
os.Exit(1)
}
if u.Variant() != uuid.RFC4122 {
fmt.Fprintf(os.Stderr, "expected RFC4122 variant, got %v\n", u.Variant())
os.Exit(1)
}
// 2. Assert uuid.Parse parses valid string representation
str := u.String()
parsed, err := uuid.Parse(str)
if err != nil {
fmt.Fprintf(os.Stderr, "uuid.Parse failed: %v\n", err)
os.Exit(1)
}
if parsed != u {
fmt.Fprintf(os.Stderr, "parsed UUID (%v) does not match original (%v)\n", parsed, u)
os.Exit(1)
}
// 3. Assert uuid.Parse rejects invalid string
if _, err := uuid.Parse("not-a-valid-uuid-string"); err == nil {
fmt.Fprintf(os.Stderr, "expected error parsing invalid uuid string, got nil\n")
os.Exit(1)
}
// 4. Assert helper functions in sample package
wrapped, err := sample.GenerateRandomUUID()
if err != nil {
fmt.Fprintf(os.Stderr, "sample.GenerateRandomUUID failed: %v\n", err)
os.Exit(1)
}
wrappedStr := wrapped.String()
parsedWrapped, err := sample.ParseUUID(wrappedStr)
if err != nil {
fmt.Fprintf(os.Stderr, "sample.ParseUUID failed: %v\n", err)
os.Exit(1)
}
if parsedWrapped != wrapped {
fmt.Fprintf(os.Stderr, "sample.ParseUUID mismatch: got %v, want %v\n", parsedWrapped, wrapped)
os.Exit(1)
}
fmt.Println("All assertions passed.")
}
Ursprungs-Seeder
anonym