Beispiel
golang.org/x/net v0.51.0: html.NewTokenizer
Verifiziertes Beispiel für golang golang.org/x/net v0.51.0: html.NewTokenizer. Der Vertrag lief auf go 1.26 · linux debian/x64 · docker und bestand.
sha256:9a95fd15235c1ad701efad5d427e96dbdb8b0bfc6ad40fca61611682bc45be2d
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
linux 24 · ubuntu · glibc 2.39 x64 go
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-09-07 |
Fall
HOW- Ziel
- verify golang.org/x/net/html.NewTokenizer in pkg:golang/golang.org/x/net@v0.51.0
- Pakete
- Symbole
-
- golang.org/x/net/html.NewTokenizer
- Erstellt
- 2026-09-07T01:15:26Z
Contract
- html.NewTokenizer tokenizes HTML stream and identifies start tags, end tags, self-closing tags, and text tokens with their attributes
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 golang.org/x/net/html.NewTokenizer in pkg:golang/golang.org/x/net@v0.51.0
Kind: HOW
Use EXACTLY these public packages and versions:
- pkg:golang/golang.org/x/net@v0.51.0
Demonstrate these symbols/APIs:
- golang.org/x/net/html.NewTokenizer
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:d8fe40970d6df181ebc873f231217336c7d0ddfb267290270b4acf0fe06e2a66","contract":["html.NewTokenizer tokenizes HTML stream and identifies start tags, end tags, self-closing tags, and text tokens with their attributes"],"goal":"verify golang.org/x/net/html.NewTokenizer in pkg:golang/golang.org/x/net@v0.51.0","kind":"HOW","packages":["pkg:golang/golang.org/x/net@v0.51.0"],"schemaVersion":1,"symbols":["golang.org/x/net/html.NewTokenizer"]},"contractCommand":["go","run","./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/golang.org/x/net@v0.51.0"],"schemaVersion":1,"subject":"pkg:golang/golang.org/x/net@v0.51.0","symbols":["golang.org/x/net/html.NewTokenizer"],"verifierAdapter":"golang@1"}
module example.com/sample
go 1.25.0
require golang.org/x/net v0.51.0
golang.org/x/net v0.51.0 h1:94R/GTO7mt3/4wIKpcR5gkGmRLOuE/2hNGeWq/GBIFo=
golang.org/x/net v0.51.0/go.mod h1:aamm+2QF5ogm02fjy5Bb7CQ0WMt1/WVM7FtyaTLlA9Y=
package main
import (
"fmt"
"io"
"log"
"strings"
"golang.org/x/net/html"
)
func main() {
rawHTML := `<div class="container"><a href="https://example.com">Link</a><img src="test.png" alt="Test" /></div>`
fmt.Println("--- Tokenizer Demo ---")
z := html.NewTokenizer(strings.NewReader(rawHTML))
for {
tt := z.Next()
if tt == html.ErrorToken {
err := z.Err()
if err == io.EOF {
break
}
log.Fatalf("tokenizer error: %v", err)
}
tok := z.Token()
switch tt {
case html.StartTagToken:
fmt.Printf("Start tag: <%s>, attrs: %v\n", tok.Data, tok.Attr)
case html.TextToken:
fmt.Printf("Text: %q\n", tok.Data)
case html.EndTagToken:
fmt.Printf("End tag: </%s>\n", tok.Data)
case html.SelfClosingTagToken:
fmt.Printf("Self-closing tag: <%s/>, attrs: %v\n", tok.Data, tok.Attr)
}
}
}
{
"schemaVersion": 1,
"goal": "verify golang.org/x/net/html.NewTokenizer in pkg:golang/golang.org/x/net@v0.51.0",
"kind": "HOW",
"packages": [
"pkg:golang/golang.org/x/net@v0.51.0"
],
"symbols": [
"golang.org/x/net/html.NewTokenizer"
]
}
package main
import (
"fmt"
"io"
"os"
"strings"
"golang.org/x/net/html"
)
func main() {
// Assertion 1: html.NewTokenizer tokenizes HTML stream and identifies start tags, end tags, self-closing tags, and text tokens with their attributes
{
input := `<div id="main"><p class="text">Hello, World!</p><img src="example.png" alt="Image" /><!-- comment --></div>`
z := html.NewTokenizer(strings.NewReader(input))
type tokenRecord struct {
tokType html.TokenType
tag string
data string
attrs map[string]string
}
var tokens []tokenRecord
for {
tt := z.Next()
if tt == html.ErrorToken {
if z.Err() == io.EOF {
break
}
fmt.Fprintf(os.Stderr, "assertion 1 failed: tokenizer error: %v\n", z.Err())
os.Exit(1)
}
tok := z.Token()
attrs := make(map[string]string)
for _, a := range tok.Attr {
attrs[a.Key] = a.Val
}
tokens = append(tokens, tokenRecord{
tokType: tt,
tag: tok.Data,
data: tok.Data,
attrs: attrs,
})
}
if len(tokens) == 0 {
fmt.Fprintf(os.Stderr, "assertion 1 failed: expected tokens, got none\n")
os.Exit(1)
}
// Verify StartTagToken <div id="main">
if tokens[0].tokType != html.StartTagToken || tokens[0].tag != "div" || tokens[0].attrs["id"] != "main" {
fmt.Fprintf(os.Stderr, "assertion 1 failed: unexpected first token %+v\n", tokens[0])
os.Exit(1)
}
// Verify StartTagToken <p class="text">
if tokens[1].tokType != html.StartTagToken || tokens[1].tag != "p" || tokens[1].attrs["class"] != "text" {
fmt.Fprintf(os.Stderr, "assertion 1 failed: unexpected second token %+v\n", tokens[1])
os.Exit(1)
}
// Verify TextToken "Hello, World!"
if tokens[2].tokType != html.TextToken || tokens[2].data != "Hello, World!" {
fmt.Fprintf(os.Stderr, "assertion 1 failed: unexpected text token %+v\n", tokens[2])
os.Exit(1)
}
// Verify EndTagToken </p>
if tokens[3].tokType != html.EndTagToken || tokens[3].tag != "p" {
fmt.Fprintf(os.Stderr, "assertion 1 failed: unexpected end tag token %+v\n", tokens[3])
os.Exit(1)
}
// Verify SelfClosingTagToken <img ... />
if tokens[4].tokType != html.SelfClosingTagToken || tokens[4].tag != "img" || tokens[4].attrs["src"] != "example.png" || tokens[4].attrs["alt"] != "Image" {
fmt.Fprintf(os.Stderr, "assertion 1 failed: unexpected self-closing tag token %+v\n", tokens[4])
os.Exit(1)
}
// Verify CommentToken
if tokens[5].tokType != html.CommentToken || tokens[5].data != " comment " {
fmt.Fprintf(os.Stderr, "assertion 1 failed: unexpected comment token %+v\n", tokens[5])
os.Exit(1)
}
// Verify EndTagToken </div>
if tokens[6].tokType != html.EndTagToken || tokens[6].tag != "div" {
fmt.Fprintf(os.Stderr, "assertion 1 failed: unexpected final end tag token %+v\n", tokens[6])
os.Exit(1)
}
// Also verify low-level TagName and TagAttr methods on tokenizer
z2 := html.NewTokenizer(strings.NewReader(`<input type="text" name="user" required />`))
if tt := z2.Next(); tt != html.SelfClosingTagToken {
fmt.Fprintf(os.Stderr, "assertion 1 failed: expected SelfClosingTagToken, got %v\n", tt)
os.Exit(1)
}
tagName, hasAttr := z2.TagName()
if string(tagName) != "input" || !hasAttr {
fmt.Fprintf(os.Stderr, "assertion 1 failed: TagName expected 'input', true; got %q, %v\n", string(tagName), hasAttr)
os.Exit(1)
}
key, val, more := z2.TagAttr()
if string(key) != "type" || string(val) != "text" || !more {
fmt.Fprintf(os.Stderr, "assertion 1 failed: first TagAttr mismatch\n")
os.Exit(1)
}
}
fmt.Println("All contract assertions passed.")
}
Ursprungs-Seeder
anonym