Beispiel
github.com/google/uuid v1.6.0: MarshalText, UnmarshalText
Verifiziertes Beispiel für golang github.com/google/uuid v1.6.0: MarshalText, UnmarshalText. Der Vertrag lief auf go 1.26 · linux alpine/x64 · docker und…
sha256:55563d7d57b6b57ae1906e21ff5a3adab1615ef563955b14231f7d4cc2eb3427
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
go 1.26 windows 11 x64 go 1.26 go go 1
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
- verify pkg:golang/github.com/google/uuid@v1.6.0
- Symbole
-
- github.com/google/uuid.MarshalText
- github.com/google/uuid.UnmarshalText
- Umgebung
- go 1.26.5
- Erstellt
- 2026-08-18T22:40:52Z
Contract
- uuid.MarshalText encodes UUID into 36-byte standard hyphenated string representation
- uuid.MarshalText encodes uuid.Nil into 36-byte zero UUID text
- uuid.UnmarshalText decodes standard 36-byte hyphenated UUID text
- uuid.UnmarshalText decodes 32-byte hex without hyphens, braced, and URN prefixed UUID text
- uuid.UnmarshalText rejects invalid UUID text with error
- uuid.MarshalText and uuid.UnmarshalText round-trip accurately preserves UUID value
Dateien
- PROMPT.md
- csx.json
- go.mod
- go.sum
- main.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: 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:ee14ae3ade3a219898f3ce45de4eb462581813fc3f002d0cae5eb137722cc8ad","contract":["uuid.MarshalText encodes UUID into 36-byte standard hyphenated string representation","uuid.MarshalText encodes uuid.Nil into 36-byte zero UUID text","uuid.UnmarshalText decodes standard 36-byte hyphenated UUID text","uuid.UnmarshalText decodes 32-byte hex without hyphens, braced, and URN prefixed UUID text","uuid.UnmarshalText rejects invalid UUID text with error","uuid.MarshalText and uuid.UnmarshalText round-trip accurately preserves UUID value"],"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":["github.com/google/uuid.MarshalText","github.com/google/uuid.UnmarshalText"]},"contractCommand":["go","run","./test"],"environment":{"arch":"x64","ecosystem":"golang","language":"go","os":"windows","osVersionBucket":"11","packageManager":"go","packageManagerVersion":"1.26.5","runtime":"go","runtimeVersion":"1.26.5","schemaVersion":1},"license":"MIT-0","packages":["pkg:golang/github.com/google/uuid@v1.6.0"],"schemaVersion":1,"symbols":["github.com/google/uuid.MarshalText","github.com/google/uuid.UnmarshalText"],"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 main
import (
"fmt"
"log"
"github.com/google/uuid"
)
// MarshalUUIDText marshals a UUID to text format.
func MarshalUUIDText(u uuid.UUID) ([]byte, error) {
return u.MarshalText()
}
// UnmarshalUUIDText parses text into a UUID.
func UnmarshalUUIDText(data []byte) (uuid.UUID, error) {
var u uuid.UUID
err := u.UnmarshalText(data)
return u, err
}
func main() {
original := uuid.New()
text, err := MarshalUUIDText(original)
if err != nil {
log.Fatalf("MarshalText failed: %v", err)
}
fmt.Printf("Marshaled text: %s\n", string(text))
restored, err := UnmarshalUUIDText(text)
if err != nil {
log.Fatalf("UnmarshalText failed: %v", err)
}
fmt.Printf("Restored UUID: %s\n", restored.String())
}
{
"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 main() {
// Assertion 1: uuid.MarshalText encodes UUID into 36-byte standard hyphenated string representation
sampleUUID, err := uuid.Parse("6ba7b810-9dad-11d1-80b4-00c04fd430c8")
if err != nil {
fmt.Fprintf(os.Stderr, "FAIL: setup parse failed: %v\n", err)
os.Exit(1)
}
marshaled, err := sampleUUID.MarshalText()
if err != nil {
fmt.Fprintf(os.Stderr, "FAIL: MarshalText failed: %v\n", err)
os.Exit(1)
}
if len(marshaled) != 36 {
fmt.Fprintf(os.Stderr, "FAIL: expected length 36, got %d\n", len(marshaled))
os.Exit(1)
}
if string(marshaled) != "6ba7b810-9dad-11d1-80b4-00c04fd430c8" {
fmt.Fprintf(os.Stderr, "FAIL: unexpected marshaled text: %s\n", string(marshaled))
os.Exit(1)
}
// Assertion 2: uuid.MarshalText encodes uuid.Nil into 36-byte zero UUID text
nilMarshaled, err := uuid.Nil.MarshalText()
if err != nil {
fmt.Fprintf(os.Stderr, "FAIL: MarshalText on Nil failed: %v\n", err)
os.Exit(1)
}
if string(nilMarshaled) != "00000000-0000-0000-0000-000000000000" {
fmt.Fprintf(os.Stderr, "FAIL: Nil UUID marshaled text mismatch: got %s\n", string(nilMarshaled))
os.Exit(1)
}
// Assertion 3: uuid.UnmarshalText decodes standard 36-byte hyphenated UUID text
var u1 uuid.UUID
if err := u1.UnmarshalText([]byte("6ba7b810-9dad-11d1-80b4-00c04fd430c8")); err != nil {
fmt.Fprintf(os.Stderr, "FAIL: UnmarshalText failed on standard format: %v\n", err)
os.Exit(1)
}
if u1 != sampleUUID {
fmt.Fprintf(os.Stderr, "FAIL: UnmarshalText standard format mismatch: got %s, want %s\n", u1, sampleUUID)
os.Exit(1)
}
// Assertion 4: uuid.UnmarshalText decodes 32-byte hex without hyphens, braced, and URN prefixed UUID text
variants := [][]byte{
[]byte("6ba7b8109dad11d180b400c04fd430c8"),
[]byte("{6ba7b810-9dad-11d1-80b4-00c04fd430c8}"),
[]byte("urn:uuid:6ba7b810-9dad-11d1-80b4-00c04fd430c8"),
}
for _, v := range variants {
var uv uuid.UUID
if err := uv.UnmarshalText(v); err != nil {
fmt.Fprintf(os.Stderr, "FAIL: UnmarshalText failed on variant %q: %v\n", string(v), err)
os.Exit(1)
}
if uv != sampleUUID {
fmt.Fprintf(os.Stderr, "FAIL: UnmarshalText variant %q mismatch: got %s, want %s\n", string(v), uv, sampleUUID)
os.Exit(1)
}
}
// Assertion 5: uuid.UnmarshalText rejects invalid UUID text with error
invalidTexts := [][]byte{
[]byte(""),
[]byte("not-a-uuid"),
[]byte("6ba7b810-9dad-11d1-80b4-00c04fd430c"),
[]byte("6ba7b810-9dad-11d1-80b4-00c04fd430c89"),
[]byte("6ba7b810-9dad-11d1-80b4-00c04fd430zz"),
}
for _, inv := range invalidTexts {
var uInv uuid.UUID
if err := uInv.UnmarshalText(inv); err == nil {
fmt.Fprintf(os.Stderr, "FAIL: expected error for invalid text %q, got nil\n", string(inv))
os.Exit(1)
}
}
// Assertion 6: uuid.MarshalText and uuid.UnmarshalText round-trip accurately preserves UUID value
randUUID := uuid.New()
encoded, err := randUUID.MarshalText()
if err != nil {
fmt.Fprintf(os.Stderr, "FAIL: MarshalText on random UUID failed: %v\n", err)
os.Exit(1)
}
var decoded uuid.UUID
if err := decoded.UnmarshalText(encoded); err != nil {
fmt.Fprintf(os.Stderr, "FAIL: UnmarshalText round-trip failed: %v\n", err)
os.Exit(1)
}
if decoded != randUUID {
fmt.Fprintf(os.Stderr, "FAIL: round-trip value mismatch: got %s, want %s\n", decoded, randUUID)
os.Exit(1)
}
if !bytes.Equal(encoded, []byte(randUUID.String())) {
fmt.Fprintf(os.Stderr, "FAIL: MarshalText output does not match String(): got %s, want %s\n", string(encoded), randUUID.String())
os.Exit(1)
}
fmt.Println("PASS: all contract assertions passed for uuid.MarshalText and uuid.UnmarshalText")
}
Ursprungs-Seeder
anonym