샘플
golang.org/x/net v0.24.0: html.ElementNode
검증된 샘플 — golang golang.org/x/net v0.24.0: html.ElementNode. go 1.26 · linux debian/x64 · docker에서 contract를 실행해 통과했습니다: html.ElementNode is a NodeType…
sha256:b6f09fe572bc30d7991374f783a842c9e7a74d158e1c1bc784e017c1bbc14d1f
이 네트워크가 제공하는 것은 하나입니다. 빌드되는 샘플. 샌드박스에서 돌리고 서명된 영수증을 보관합니다. 등급을 매기지 않고 무엇도 보증하지 않습니다 — 같은 코드가 당신 환경에서 빌드되는지는 측정한 적이 없습니다.
통과한 계약 영수증을 낸 서로 다른 서명 키의 수입니다. 하나면 작성자 혼자이고, 둘 이상이면 다른 사람도 빌드했다는 뜻입니다. 키는 스스로 만드는 것이고 뒤에 등록된 신원이 없으므로, 세는 것은 사람이 아니라 키입니다.
MIT-0
실행 증거
선언된 환경과 서명된 실행을 분리해 두었습니다. 이 샘플이 무엇을 어디서 실행했는지 그대로 볼 수 있습니다.
- 증거 기준
- 서명된 컨트랙트 통과
- 검증 영수증
- 1
- 빌드한 서명 키
- 1
선언된 환경
go 1.26 linux 24 · ubuntu · glibc 2.39 x64 go 1.26 go go 1
검증 실행 환경
| 환경 | 컨트랙트 | 단계 | 실행일 |
|---|---|---|---|
| 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-04 |
케이스
HOW- 목표
- verify golang.org/x/net/html.ElementNode in pkg:golang/golang.org/x/net@v0.24.0
- 심벌
-
- golang.org/x/net/html.ElementNode
- 환경
- go 1.26.6
- 생성일
- 2026-09-04T13:26:10Z
컨트랙트
- html.ElementNode is a NodeType distinguishing HTML element nodes from document and text nodes
- html.Parse parses HTML string into a DOM tree containing ElementNode with expected tag names
- html.ElementNode contains Attr slice representing HTML attributes with Key and Val
- html.ElementNode supports tree mutation via AppendChild and RemoveChild maintaining parent and sibling pointers
- html.Render serializes a tree of ElementNode nodes back into valid HTML output
- html.ParseFragment parses HTML fragment using an ElementNode context node
파일
- PROMPT.md
- csx.json
- go.mod
- go.sum
- main.go
- spec.json
- test/contract.go
소스
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.ElementNode in pkg:golang/golang.org/x/net@v0.24.0
Kind: HOW
Use EXACTLY these public packages and versions:
- pkg:golang/golang.org/x/net@v0.24.0
Demonstrate these symbols/APIs:
- golang.org/x/net/html.ElementNode
Required runtime conditions:
- ecosystem: golang
- language: go
- packageManager: go@1.26.6
- runtime: go@1.26.6
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:750bc650a262e0ea7058ada44434a795c3bc8971e8d1e77ddcda2bf569caccff","contract":["html.ElementNode is a NodeType distinguishing HTML element nodes from document and text nodes","html.Parse parses HTML string into a DOM tree containing ElementNode with expected tag names","html.ElementNode contains Attr slice representing HTML attributes with Key and Val","html.ElementNode supports tree mutation via AppendChild and RemoveChild maintaining parent and sibling pointers","html.Render serializes a tree of ElementNode nodes back into valid HTML output","html.ParseFragment parses HTML fragment using an ElementNode context node"],"goal":"verify golang.org/x/net/html.ElementNode in pkg:golang/golang.org/x/net@v0.24.0","kind":"HOW","packages":["pkg:golang/golang.org/x/net@v0.24.0"],"schemaVersion":1,"symbols":["golang.org/x/net/html.ElementNode"]},"contractCommand":["go","run","./test"],"environment":{"arch":"x64","distro":"ubuntu","ecosystem":"golang","language":"go","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/net@v0.24.0"],"schemaVersion":1,"subject":"pkg:golang/golang.org/x/net@v0.24.0","symbols":["golang.org/x/net/html.ElementNode"],"verifierAdapter":"golang@1"}
module example.com/sample
go 1.24.0
require golang.org/x/net v0.24.0
golang.org/x/net v0.24.0 h1:1PcaxkF854Fu3+lvBIx5SYn9wRlBzzcnHZSiaFFAb0w=
golang.org/x/net v0.24.0/go.mod h1:2Q7sJY5mzlzWjKtYUEXSlBWCdyaioyXzRB2RtU8KVE8=
package main
import (
"bytes"
"fmt"
"strings"
"golang.org/x/net/html"
"golang.org/x/net/html/atom"
)
func main() {
rawHTML := `<div class="container" id="main"><p>CodeSampleX Demo</p></div>`
doc, err := html.Parse(strings.NewReader(rawHTML))
if err != nil {
panic(err)
}
var visit func(*html.Node)
visit = func(n *html.Node) {
if n.Type == html.ElementNode {
fmt.Printf("Element: <%s>\n", n.Data)
for _, attr := range n.Attr {
fmt.Printf(" Attr: %s=%s\n", attr.Key, attr.Val)
}
}
for c := n.FirstChild; c != nil; c = c.NextSibling {
visit(c)
}
}
visit(doc)
// Create and append an ElementNode programmatically
newElem := &html.Node{
Type: html.ElementNode,
DataAtom: atom.Span,
Data: "span",
Attr: []html.Attribute{
{Key: "class", Val: "badge"},
},
}
doc.AppendChild(newElem)
var buf bytes.Buffer
if err := html.Render(&buf, doc); err != nil {
panic(err)
}
fmt.Printf("Rendered HTML:\n%s\n", buf.String())
}
{
"schemaVersion": 1,
"goal": "verify golang.org/x/net/html.ElementNode in pkg:golang/golang.org/x/net@v0.24.0",
"kind": "HOW",
"packages": [
"pkg:golang/golang.org/x/net@v0.24.0"
],
"symbols": [
"golang.org/x/net/html.ElementNode"
],
"runtimeConditions": {
"ecosystem": "golang",
"language": "go",
"packageManager": "go@1.26.6",
"runtime": "go@1.26.6"
}
}
package main
import (
"bytes"
"fmt"
"os"
"strings"
"golang.org/x/net/html"
"golang.org/x/net/html/atom"
)
func main() {
// 1. html.ElementNode is a NodeType distinguishing HTML element nodes from document and text nodes
if html.ElementNode == html.DocumentNode {
fmt.Fprintf(os.Stderr, "Contract 1 failed: ElementNode must not equal DocumentNode\n")
os.Exit(1)
}
if html.ElementNode == html.TextNode {
fmt.Fprintf(os.Stderr, "Contract 1 failed: ElementNode must not equal TextNode\n")
os.Exit(1)
}
if html.ElementNode == html.CommentNode {
fmt.Fprintf(os.Stderr, "Contract 1 failed: ElementNode must not equal CommentNode\n")
os.Exit(1)
}
// 2. html.Parse parses HTML string into a DOM tree containing ElementNode with expected tag names
rawHTML := `<!DOCTYPE html><html><head><title>Test</title></head><body><div id="content"><p>Hello</p></div></body></html>`
doc, err := html.Parse(strings.NewReader(rawHTML))
if err != nil {
fmt.Fprintf(os.Stderr, "Contract 2 failed: html.Parse error: %v\n", err)
os.Exit(1)
}
if doc == nil || doc.Type != html.DocumentNode {
fmt.Fprintf(os.Stderr, "Contract 2 failed: root node must be DocumentNode\n")
os.Exit(1)
}
var elementTags []string
var findElements func(*html.Node)
findElements = func(n *html.Node) {
if n.Type == html.ElementNode {
elementTags = append(elementTags, n.Data)
}
for c := n.FirstChild; c != nil; c = c.NextSibling {
findElements(c)
}
}
findElements(doc)
expectedTags := []string{"html", "head", "title", "body", "div", "p"}
if len(elementTags) != len(expectedTags) {
fmt.Fprintf(os.Stderr, "Contract 2 failed: element tags length mismatch: got %v, want %v\n", elementTags, expectedTags)
os.Exit(1)
}
for i, tag := range expectedTags {
if elementTags[i] != tag {
fmt.Fprintf(os.Stderr, "Contract 2 failed: tag at %d mismatch: got %s, want %s\n", i, elementTags[i], tag)
os.Exit(1)
}
}
// 3. html.ElementNode contains Attr slice representing HTML attributes with Key and Val
var divNode *html.Node
var findDiv func(*html.Node)
findDiv = func(n *html.Node) {
if n.Type == html.ElementNode && n.Data == "div" {
divNode = n
return
}
for c := n.FirstChild; c != nil; c = c.NextSibling {
findDiv(c)
}
}
findDiv(doc)
if divNode == nil {
fmt.Fprintf(os.Stderr, "Contract 3 failed: div ElementNode not found\n")
os.Exit(1)
}
if len(divNode.Attr) != 1 || divNode.Attr[0].Key != "id" || divNode.Attr[0].Val != "content" {
fmt.Fprintf(os.Stderr, "Contract 3 failed: div Attr mismatch: got %+v\n", divNode.Attr)
os.Exit(1)
}
// 4. html.ElementNode supports tree mutation via AppendChild and RemoveChild maintaining parent and sibling pointers
parent := &html.Node{
Type: html.ElementNode,
DataAtom: atom.Ul,
Data: "ul",
}
child1 := &html.Node{
Type: html.ElementNode,
DataAtom: atom.Li,
Data: "li",
}
child2 := &html.Node{
Type: html.ElementNode,
DataAtom: atom.Li,
Data: "li",
}
parent.AppendChild(child1)
parent.AppendChild(child2)
if parent.FirstChild != child1 || parent.LastChild != child2 {
fmt.Fprintf(os.Stderr, "Contract 4 failed: AppendChild pointers mismatch\n")
os.Exit(1)
}
if child1.Parent != parent || child2.Parent != parent {
fmt.Fprintf(os.Stderr, "Contract 4 failed: child Parent pointer mismatch\n")
os.Exit(1)
}
if child1.NextSibling != child2 || child2.PrevSibling != child1 {
fmt.Fprintf(os.Stderr, "Contract 4 failed: sibling pointers mismatch\n")
os.Exit(1)
}
parent.RemoveChild(child1)
if parent.FirstChild != child2 || child1.Parent != nil || child1.NextSibling != nil {
fmt.Fprintf(os.Stderr, "Contract 4 failed: RemoveChild pointers mismatch\n")
os.Exit(1)
}
// 5. html.Render serializes a tree of ElementNode nodes back into valid HTML output
var renderBuf bytes.Buffer
if err := html.Render(&renderBuf, parent); err != nil {
fmt.Fprintf(os.Stderr, "Contract 5 failed: html.Render error: %v\n", err)
os.Exit(1)
}
expectedRendered := "<ul><li></li></ul>"
if renderBuf.String() != expectedRendered {
fmt.Fprintf(os.Stderr, "Contract 5 failed: html.Render mismatch: got %q, want %q\n", renderBuf.String(), expectedRendered)
os.Exit(1)
}
// 6. html.ParseFragment parses HTML fragment using an ElementNode context node
contextNode := &html.Node{
Type: html.ElementNode,
DataAtom: atom.Div,
Data: "div",
}
fragHTML := `<span class="frag">fragment text</span>`
nodes, err := html.ParseFragment(strings.NewReader(fragHTML), contextNode)
if err != nil {
fmt.Fprintf(os.Stderr, "Contract 6 failed: html.ParseFragment error: %v\n", err)
os.Exit(1)
}
if len(nodes) != 1 {
fmt.Fprintf(os.Stderr, "Contract 6 failed: nodes length mismatch: got %d, want 1\n", len(nodes))
os.Exit(1)
}
fragElem := nodes[0]
if fragElem.Type != html.ElementNode || fragElem.Data != "span" {
fmt.Fprintf(os.Stderr, "Contract 6 failed: fragElem mismatch: Type=%v, Data=%s\n", fragElem.Type, fragElem.Data)
os.Exit(1)
}
if len(fragElem.Attr) != 1 || fragElem.Attr[0].Key != "class" || fragElem.Attr[0].Val != "frag" {
fmt.Fprintf(os.Stderr, "Contract 6 failed: fragElem Attr mismatch: %+v\n", fragElem.Attr)
os.Exit(1)
}
fmt.Println("All contract assertions passed.")
}
오리진 시더
익명