Beispiel
golang.org/x/net v0.61.0: html.NodeType
Verifiziertes Beispiel für golang golang.org/x/net v0.61.0: html.NodeType. Der Vertrag lief auf go 1.26 · linux debian/x64 · docker und bestand.
sha256:c6896242066fc0b809a3e3a370114e7221d949acfee1c4569eadfc3e99396548
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-10-11 |
Fall
HOW- Ziel
- verify golang.org/x/net/html.NodeType in pkg:golang/golang.org/x/net@v0.61.0
- Pakete
- Symbole
-
- golang.org/x/net/html.NodeType
- Erstellt
- 2026-10-11T20:08:38Z
Contract
- html.NodeType constants identify the distinct kinds of DOM nodes including DocumentNode, ElementNode, TextNode, CommentNode, and DoctypeNode
- html.Parse populates the Type field of each node in the parsed tree with the corresponding html.NodeType value
- A programmatically created html.Node retains its assigned html.NodeType during tree construction and manipulation
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.NodeType in pkg:golang/golang.org/x/net@v0.61.0
Kind: HOW
Use EXACTLY these public packages and versions:
- pkg:golang/golang.org/x/net@v0.61.0
Demonstrate these symbols/APIs:
- golang.org/x/net/html.NodeType
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:1e0dca525c4461fd6193a1a1ce2484d76cefed26fcda468db776a55450d3c8e3","contract":["html.NodeType constants identify the distinct kinds of DOM nodes including DocumentNode, ElementNode, TextNode, CommentNode, and DoctypeNode","html.Parse populates the Type field of each node in the parsed tree with the corresponding html.NodeType value","A programmatically created html.Node retains its assigned html.NodeType during tree construction and manipulation"],"goal":"verify golang.org/x/net/html.NodeType in pkg:golang/golang.org/x/net@v0.61.0","kind":"HOW","packages":["pkg:golang/golang.org/x/net@v0.61.0"],"schemaVersion":1,"symbols":["golang.org/x/net/html.NodeType"]},"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.61.0"],"schemaVersion":1,"subject":"pkg:golang/golang.org/x/net@v0.61.0","symbols":["golang.org/x/net/html.NodeType"],"verifierAdapter":"golang@1"}
module example.com/sample
go 1.26.0
require golang.org/x/net v0.61.0
golang.org/x/net v0.61.0 h1:RR+6j/BTBCrggOLugxa+66R8FvoN6MHlzDlZIbN9YFw=
golang.org/x/net v0.61.0/go.mod h1:WgDCOTH8iwtB66T4/GfI94AHo/hhdb7Hah9NDseQfiI=
package main
import (
"fmt"
"log"
"strings"
"golang.org/x/net/html"
)
// ClassifyNodeType returns a human-readable name for an html.NodeType.
func ClassifyNodeType(nt html.NodeType) string {
switch nt {
case html.ErrorNode:
return "ErrorNode"
case html.TextNode:
return "TextNode"
case html.DocumentNode:
return "DocumentNode"
case html.ElementNode:
return "ElementNode"
case html.CommentNode:
return "CommentNode"
case html.DoctypeNode:
return "DoctypeNode"
case html.RawNode:
return "RawNode"
default:
return fmt.Sprintf("NodeType(%d)", nt)
}
}
// CountNodeTypes traverses an HTML document tree and returns a map of NodeType to count.
func CountNodeTypes(n *html.Node) map[html.NodeType]int {
counts := make(map[html.NodeType]int)
var walk func(*html.Node)
walk = func(curr *html.Node) {
if curr == nil {
return
}
counts[curr.Type]++
for c := curr.FirstChild; c != nil; c = c.NextSibling {
walk(c)
}
}
walk(n)
return counts
}
func main() {
sampleHTML := `<!DOCTYPE html><html><!-- sample comment --><body><h1>Hello World</h1></body></html>`
doc, err := html.Parse(strings.NewReader(sampleHTML))
if err != nil {
log.Fatalf("failed to parse HTML: %v", err)
}
counts := CountNodeTypes(doc)
fmt.Printf("Root node type: %s\n", ClassifyNodeType(doc.Type))
for nt, count := range counts {
fmt.Printf(" %s: %d\n", ClassifyNodeType(nt), count)
}
}
{
"schemaVersion": 1,
"goal": "verify golang.org/x/net/html.NodeType in pkg:golang/golang.org/x/net@v0.61.0",
"kind": "HOW",
"packages": [
"pkg:golang/golang.org/x/net@v0.61.0"
],
"symbols": [
"golang.org/x/net/html.NodeType"
]
}
package main
import (
"fmt"
"os"
"strings"
"golang.org/x/net/html"
)
func main() {
// Assertion 1: html.NodeType constants identify the distinct kinds of DOM nodes including DocumentNode, ElementNode, TextNode, CommentNode, and DoctypeNode
expectedConstants := map[html.NodeType]uint32{
html.ErrorNode: 0,
html.TextNode: 1,
html.DocumentNode: 2,
html.ElementNode: 3,
html.CommentNode: 4,
html.DoctypeNode: 5,
html.RawNode: 6,
}
for nt, val := range expectedConstants {
if uint32(nt) != val {
fmt.Fprintf(os.Stderr, "assertion 1 failed: expected NodeType %d to have value %d, got %d\n", nt, val, uint32(nt))
os.Exit(1)
}
}
types := []html.NodeType{
html.ErrorNode,
html.TextNode,
html.DocumentNode,
html.ElementNode,
html.CommentNode,
html.DoctypeNode,
html.RawNode,
}
seen := make(map[html.NodeType]bool)
for _, t := range types {
if seen[t] {
fmt.Fprintf(os.Stderr, "assertion 1 failed: duplicate NodeType %d\n", t)
os.Exit(1)
}
seen[t] = true
}
// Assertion 2: html.Parse populates the Type field of each node in the parsed tree with the corresponding html.NodeType value
htmlDoc := `<!DOCTYPE html><html><!-- comment --><body><p>Sample Text</p></body></html>`
doc, err := html.Parse(strings.NewReader(htmlDoc))
if err != nil {
fmt.Fprintf(os.Stderr, "assertion 2 failed: html.Parse error: %v\n", err)
os.Exit(1)
}
if doc.Type != html.DocumentNode {
fmt.Fprintf(os.Stderr, "assertion 2 failed: expected root Type DocumentNode, got %v\n", doc.Type)
os.Exit(1)
}
nodeTypeCounts := make(map[html.NodeType]int)
var collectTypes func(*html.Node)
collectTypes = func(n *html.Node) {
if n == nil {
return
}
nodeTypeCounts[n.Type]++
for c := n.FirstChild; c != nil; c = c.NextSibling {
collectTypes(c)
}
}
collectTypes(doc)
if nodeTypeCounts[html.DocumentNode] != 1 {
fmt.Fprintf(os.Stderr, "assertion 2 failed: expected 1 DocumentNode, got %d\n", nodeTypeCounts[html.DocumentNode])
os.Exit(1)
}
if nodeTypeCounts[html.DoctypeNode] != 1 {
fmt.Fprintf(os.Stderr, "assertion 2 failed: expected 1 DoctypeNode, got %d\n", nodeTypeCounts[html.DoctypeNode])
os.Exit(1)
}
if nodeTypeCounts[html.CommentNode] != 1 {
fmt.Fprintf(os.Stderr, "assertion 2 failed: expected 1 CommentNode, got %d\n", nodeTypeCounts[html.CommentNode])
os.Exit(1)
}
if nodeTypeCounts[html.ElementNode] < 4 {
fmt.Fprintf(os.Stderr, "assertion 2 failed: expected at least 4 ElementNodes, got %d\n", nodeTypeCounts[html.ElementNode])
os.Exit(1)
}
if nodeTypeCounts[html.TextNode] < 1 {
fmt.Fprintf(os.Stderr, "assertion 2 failed: expected at least 1 TextNode, got %d\n", nodeTypeCounts[html.TextNode])
os.Exit(1)
}
// Assertion 3: A programmatically created html.Node retains its assigned html.NodeType during tree construction and manipulation
customElement := &html.Node{
Type: html.ElementNode,
Data: "div",
}
customText := &html.Node{
Type: html.TextNode,
Data: "Dynamic Content",
}
customComment := &html.Node{
Type: html.CommentNode,
Data: "Dynamic Comment",
}
customElement.AppendChild(customComment)
customElement.AppendChild(customText)
if customElement.Type != html.ElementNode {
fmt.Fprintf(os.Stderr, "assertion 3 failed: expected ElementNode, got %v\n", customElement.Type)
os.Exit(1)
}
if customElement.FirstChild.Type != html.CommentNode {
fmt.Fprintf(os.Stderr, "assertion 3 failed: expected CommentNode, got %v\n", customElement.FirstChild.Type)
os.Exit(1)
}
if customElement.LastChild.Type != html.TextNode {
fmt.Fprintf(os.Stderr, "assertion 3 failed: expected TextNode, got %v\n", customElement.LastChild.Type)
os.Exit(1)
}
fmt.Println("All contract assertions passed.")
}
Ursprungs-Seeder
anonym