Beispiel
golang.org/x/tools v0.1.1: txtar.Format
Verifiziertes Beispiel für golang golang.org/x/tools v0.1.1: txtar.Format. Der Vertrag lief auf go 1.26 · linux debian/x64 · docker und bestand.
sha256:70abba3cb3fb8f23c98aca26f2153bb3b7f14065d96983dcf0e8922bc9fa686f
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
- 1
- Signaturschlüssel, die es gebaut haben
- 1
Deklarierte Umgebung
go 1.26 linux 24 · ubuntu · glibc 2.39 amd64 go 1.26 go 1.26 go 1
Umgebungen der Verifizierungsläufe
| Umgebung | Contract | Stufen | Lauf |
|---|---|---|---|
| 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-10-13 |
Fall
HOW- Ziel
- verify golang.org/x/tools/txtar.Format in pkg:golang/golang.org/x/tools@v0.1.1
- Pakete
- Symbole
-
- golang.org/x/tools/txtar.Format
- Umgebung
- go 1.26.6
- Erstellt
- 2026-10-13T23:44:39Z
Contract
- txtar.Format serializes an Archive containing comment and files into txtar format bytes
- txtar.Format delimits files with '-- filename --' marker lines
- txtar.Format output round-trips identically with txtar.Parse
- txtar.Format appends trailing newline to files without trailing newlines
Dateien
- PROMPT.md
- contract_test.go
- csx.json
- go.mod
- go.sum
- sample.go
- spec.json
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 golang.org/x/tools/txtar.Format in pkg:golang/golang.org/x/tools@v0.1.1
Kind: HOW
Use EXACTLY these public packages and versions:
- pkg:golang/golang.org/x/tools@v0.1.1
Demonstrate these symbols/APIs:
- golang.org/x/tools/txtar.Format
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 (
"bytes"
"strings"
"testing"
"golang.org/x/tools/txtar"
)
func TestContractTxtarFormat(t *testing.T) {
// 1. Verify txtar.Format serializes an Archive containing comment and files into txtar format bytes
archive := &txtar.Archive{
Comment: []byte("This is a sample archive comment.\n"),
Files: []txtar.File{
{
Name: "file1.txt",
Data: []byte("hello world\n"),
},
{
Name: "dir/file2.txt",
Data: []byte("line 1\nline 2\n"),
},
},
}
formatted := txtar.Format(archive)
if len(formatted) == 0 {
t.Fatalf("expected formatted output to be non-empty")
}
str := string(formatted)
if !strings.HasPrefix(str, "This is a sample archive comment.") {
t.Errorf("expected comment at start, got %q", str)
}
// 2. Verify txtar.Format delimits files with '-- filename --' marker lines
if !strings.Contains(str, "-- file1.txt --\nhello world\n") {
t.Errorf("expected file1.txt content with delimiter, got %q", str)
}
if !strings.Contains(str, "-- dir/file2.txt --\nline 1\nline 2\n") {
t.Errorf("expected dir/file2.txt content with delimiter, got %q", str)
}
// 3. Verify txtar.Format output round-trips identically with txtar.Parse
parsed := txtar.Parse(formatted)
if !bytes.Equal(bytes.TrimSpace(parsed.Comment), bytes.TrimSpace(archive.Comment)) {
t.Errorf("roundtrip comment mismatch: got %q, want %q", parsed.Comment, archive.Comment)
}
if len(parsed.Files) != len(archive.Files) {
t.Fatalf("roundtrip files length mismatch: got %d, want %d", len(parsed.Files), len(archive.Files))
}
for i, f := range parsed.Files {
if f.Name != archive.Files[i].Name {
t.Errorf("file %d name mismatch: got %s, want %s", i, f.Name, archive.Files[i].Name)
}
if !bytes.Equal(bytes.TrimSpace(f.Data), bytes.TrimSpace(archive.Files[i].Data)) {
t.Errorf("file %d data mismatch: got %q, want %q", i, f.Data, archive.Files[i].Data)
}
}
// 4. Verify txtar.Format appends trailing newline to files without trailing newlines
noNewlineArchive := &txtar.Archive{
Files: []txtar.File{
{
Name: "test.txt",
Data: []byte("no newline"),
},
},
}
noNewlineFormatted := txtar.Format(noNewlineArchive)
if !strings.HasSuffix(string(noNewlineFormatted), "no newline\n") {
t.Errorf("expected trailing newline appended, got %q", string(noNewlineFormatted))
}
}
{"case":{"caseId":"case:sha256:e40ed68e181e4adf88930c51b57363b8fc49f0d45588e424e430c7be1f74e14b","contract":["txtar.Format serializes an Archive containing comment and files into txtar format bytes","txtar.Format delimits files with '-- filename --' marker lines","txtar.Format output round-trips identically with txtar.Parse","txtar.Format appends trailing newline to files without trailing newlines"],"goal":"verify golang.org/x/tools/txtar.Format in pkg:golang/golang.org/x/tools@v0.1.1","kind":"HOW","packages":["pkg:golang/golang.org/x/tools@v0.1.1"],"schemaVersion":1,"symbols":["golang.org/x/tools/txtar.Format"]},"contractCommand":["go","test","./..."],"environment":{"arch":"amd64","compiler":"go","compilerVersion":"1.26.6","distro":"ubuntu","ecosystem":"golang","language":"go","languageVersion":"1.26.6","libc":"glibc","libcVersion":"2.39","os":"linux","osVersionBucket":"24","packageManager":"go","packageManagerVersion":"1.26.6","runtime":"go","runtimeVersion":"1.26.6","schemaVersion":1},"license":"MIT-0","packages":["pkg:golang/golang.org/x/tools@v0.1.1"],"schemaVersion":1,"subject":"pkg:golang/golang.org/x/tools@v0.1.1","symbols":["golang.org/x/tools/txtar.Format"],"verifierAdapter":"golang@1"}
module example.com/sample
go 1.26.6
require golang.org/x/tools v0.1.1
golang.org/x/tools v0.1.1 h1:wGiQel/hW0NnEkJUk8lbzkX2gFJU6PFxf1v5OlCfuOs=
golang.org/x/tools v0.1.1/go.mod h1:o0xws9oXOQQZyjljx8fwUC0k7L1pTE6eaCbjGeHmOkk=
package sample
import (
"golang.org/x/tools/txtar"
)
// FormatArchive serializes a txtar.Archive into txtar byte format using txtar.Format.
func FormatArchive(comment string, files map[string]string) []byte {
var archiveFiles []txtar.File
for name, data := range files {
archiveFiles = append(archiveFiles, txtar.File{
Name: name,
Data: []byte(data),
})
}
a := &txtar.Archive{
Comment: []byte(comment),
Files: archiveFiles,
}
return txtar.Format(a)
}
// ParseArchive parses txtar formatted bytes into a txtar.Archive using txtar.Parse.
func ParseArchive(data []byte) *txtar.Archive {
return txtar.Parse(data)
}
{
"schemaVersion": 1,
"goal": "verify golang.org/x/tools/txtar.Format in pkg:golang/golang.org/x/tools@v0.1.1",
"kind": "HOW",
"packages": [
"pkg:golang/golang.org/x/tools@v0.1.1"
],
"symbols": [
"golang.org/x/tools/txtar.Format"
]
}
Ursprungs-Seeder
anonym