샘플
golang.org/x/net v0.41.0: atom.Atom
검증된 샘플 — golang golang.org/x/net v0.41.0: atom.Atom. go 1.26 · linux debian/x64 · docker에서 contract를 실행해 통과했습니다: atom.Atom zero value atom.Atom(0) maps to…
sha256:e200d707e3ddad494e184fe2603af6c2bccdf81ed3afffb8bda0b3eb7d9b15d9
이 네트워크가 제공하는 것은 하나입니다. 빌드되는 샘플. 샌드박스에서 돌리고 서명된 영수증을 보관합니다. 등급을 매기지 않고 무엇도 보증하지 않습니다 — 같은 코드가 당신 환경에서 빌드되는지는 측정한 적이 없습니다.
통과한 계약 영수증을 낸 서로 다른 서명 키의 수입니다. 하나면 작성자 혼자이고, 둘 이상이면 다른 사람도 빌드했다는 뜻입니다. 키는 스스로 만드는 것이고 뒤에 등록된 신원이 없으므로, 세는 것은 사람이 아니라 키입니다.
MIT-0
실행 증거
선언된 환경과 서명된 실행을 분리해 두었습니다. 이 샘플이 무엇을 어디서 실행했는지 그대로 볼 수 있습니다.
- 증거 기준
- 서명된 컨트랙트 통과
- 검증 영수증
- 1
- 빌드한 서명 키
- 1
선언된 환경
linux 24 · ubuntu · glibc 2.39 x64 go
검증 실행 환경
| 환경 | 컨트랙트 | 단계 | 실행일 |
|---|---|---|---|
| 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-15 |
케이스
HOW- 목표
- verify golang.org/x/net/html/atom.Atom in pkg:golang/golang.org/x/net@v0.41.0
- 심벌
-
- golang.org/x/net/html/atom.Atom
- 생성일
- 2026-10-15T02:18:25Z
컨트랙트
- atom.Atom zero value atom.Atom(0) maps to empty string ""
- atom.Atom constants have non-zero integer codes whose String() returns their lowercase tag or attribute name
- atom.Lookup resolves valid HTML tag byte slices to non-zero atom.Atom and returns atom.Atom(0) for unknown or uppercase tags
- html.Parse assigns atom.Atom to html.Node.DataAtom for known HTML tags and zero for custom tags
- atom.Atom supports direct integer equality comparison between element DataAtom and atom constants
파일
- PROMPT.md
- atom_sample.go
- csx.json
- go.mod
- go.sum
- 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/atom.Atom in pkg:golang/golang.org/x/net@v0.41.0
Kind: HOW
Use EXACTLY these public packages and versions:
- pkg:golang/golang.org/x/net@v0.41.0
Demonstrate these symbols/APIs:
- golang.org/x/net/html/atom.Atom
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 (
"strings"
"golang.org/x/net/html"
"golang.org/x/net/html/atom"
)
// IsValidAtom returns true when the atom has a non-zero integer code.
func IsValidAtom(a atom.Atom) bool {
return a != 0
}
// AtomString returns the lowercase name of the atom.
func AtomString(a atom.Atom) string {
return a.String()
}
// LookupTagAtom resolves a lowercase tag byte slice into an atom.Atom.
func LookupTagAtom(tag []byte) atom.Atom {
return atom.Lookup(tag)
}
// NodeHasAtom checks if an html.Node has the specified DataAtom.
func NodeHasAtom(n *html.Node, expected atom.Atom) bool {
if n == nil {
return false
}
return n.DataAtom == expected
}
// FindElementByAtom traverses the HTML node tree and returns the first ElementNode with the given atom.Atom.
func FindElementByAtom(root *html.Node, target atom.Atom) *html.Node {
if root == nil {
return nil
}
if root.Type == html.ElementNode && root.DataAtom == target {
return root
}
for child := root.FirstChild; child != nil; child = child.NextSibling {
if found := FindElementByAtom(child, target); found != nil {
return found
}
}
return nil
}
// ParseHTMLDoc parses an HTML fragment or document into an html.Node tree.
func ParseHTMLDoc(src string) (*html.Node, error) {
return html.Parse(strings.NewReader(src))
}
{"case":{"caseId":"case:sha256:9758fbe8cef66865e29bbdddd1c48d35ba8355b461fbc3e6fbf7bd1c8ec31503","contract":["atom.Atom zero value atom.Atom(0) maps to empty string \"\"","atom.Atom constants have non-zero integer codes whose String() returns their lowercase tag or attribute name","atom.Lookup resolves valid HTML tag byte slices to non-zero atom.Atom and returns atom.Atom(0) for unknown or uppercase tags","html.Parse assigns atom.Atom to html.Node.DataAtom for known HTML tags and zero for custom tags","atom.Atom supports direct integer equality comparison between element DataAtom and atom constants"],"goal":"verify golang.org/x/net/html/atom.Atom in pkg:golang/golang.org/x/net@v0.41.0","kind":"HOW","packages":["pkg:golang/golang.org/x/net@v0.41.0"],"schemaVersion":1,"symbols":["golang.org/x/net/html/atom.Atom"]},"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.41.0"],"schemaVersion":1,"subject":"pkg:golang/golang.org/x/net@v0.41.0","symbols":["golang.org/x/net/html/atom.Atom"],"verifierAdapter":"golang@1"}
module example.com/atomsample
go 1.23.0
require golang.org/x/net v0.41.0
golang.org/x/net v0.41.0 h1:vBTly1HeNPEn3wtREYfy4GZ/NECgw2Cnl+nK6Nz3uvw=
golang.org/x/net v0.41.0/go.mod h1:B/K4NNqkfmg07DQYrbwvSluqCJOOXwUjeb/5lOisjbA=
{
"schemaVersion": 1,
"goal": "verify golang.org/x/net/html/atom.Atom in pkg:golang/golang.org/x/net@v0.41.0",
"kind": "HOW",
"packages": [
"pkg:golang/golang.org/x/net@v0.41.0"
],
"symbols": [
"golang.org/x/net/html/atom.Atom"
]
}
package main
import (
"fmt"
"os"
sample "example.com/atomsample"
"golang.org/x/net/html"
"golang.org/x/net/html/atom"
)
func main() {
// 1. Zero value atom.Atom(0) maps to empty string ""
var zeroAtom atom.Atom
if zeroAtom != 0 {
fmt.Fprintf(os.Stderr, "FAIL: expected zero atom to equal 0, got %v\n", zeroAtom)
os.Exit(1)
}
if zeroAtom.String() != "" {
fmt.Fprintf(os.Stderr, "FAIL: expected zeroAtom.String() == \"\", got %q\n", zeroAtom.String())
os.Exit(1)
}
if sample.IsValidAtom(zeroAtom) {
fmt.Fprintf(os.Stderr, "FAIL: expected IsValidAtom(0) == false\n")
os.Exit(1)
}
// 2. Known atom.Atom constants have non-zero integer codes whose String() returns their lowercase name
knownAtoms := []struct {
code atom.Atom
name string
}{
{atom.Div, "div"},
{atom.Span, "span"},
{atom.A, "a"},
{atom.P, "p"},
{atom.Body, "body"},
{atom.Table, "table"},
{atom.Input, "input"},
}
for _, tc := range knownAtoms {
if tc.code == 0 {
fmt.Fprintf(os.Stderr, "FAIL: expected non-zero atom for %s\n", tc.name)
os.Exit(1)
}
if tc.code.String() != tc.name {
fmt.Fprintf(os.Stderr, "FAIL: expected %s.String() == %q, got %q\n", tc.name, tc.name, tc.code.String())
os.Exit(1)
}
if sample.AtomString(tc.code) != tc.name {
fmt.Fprintf(os.Stderr, "FAIL: expected AtomString(%s) == %q, got %q\n", tc.name, tc.name, sample.AtomString(tc.code))
os.Exit(1)
}
if !sample.IsValidAtom(tc.code) {
fmt.Fprintf(os.Stderr, "FAIL: expected IsValidAtom(%s) == true\n", tc.name)
os.Exit(1)
}
}
// 3. atom.Lookup resolves valid lowercase HTML tag byte slices to non-zero atom.Atom and returns 0 for unknown or uppercase tags
if got := sample.LookupTagAtom([]byte("div")); got != atom.Div {
fmt.Fprintf(os.Stderr, "FAIL: LookupTagAtom(\"div\") expected atom.Div, got %v\n", got)
os.Exit(1)
}
if got := sample.LookupTagAtom([]byte("DIV")); got != 0 {
fmt.Fprintf(os.Stderr, "FAIL: LookupTagAtom(\"DIV\") expected 0, got %v\n", got)
os.Exit(1)
}
if got := sample.LookupTagAtom([]byte("x-custom-tag")); got != 0 {
fmt.Fprintf(os.Stderr, "FAIL: LookupTagAtom(\"x-custom-tag\") expected 0, got %v\n", got)
os.Exit(1)
}
if got := sample.LookupTagAtom([]byte("")); got != 0 {
fmt.Fprintf(os.Stderr, "FAIL: LookupTagAtom(\"\") expected 0, got %v\n", got)
os.Exit(1)
}
// 4. html.Parse assigns atom.Atom to html.Node.DataAtom for known HTML tags and zero for custom tags
doc, err := sample.ParseHTMLDoc(`<!DOCTYPE html><html><body><div id="main"><span class="label">Hello</span><x-custom>Item</x-custom></div></body></html>`)
if err != nil {
fmt.Fprintf(os.Stderr, "FAIL: ParseHTMLDoc error: %v\n", err)
os.Exit(1)
}
divNode := sample.FindElementByAtom(doc, atom.Div)
if divNode == nil {
fmt.Fprintf(os.Stderr, "FAIL: FindElementByAtom(atom.Div) returned nil\n")
os.Exit(1)
}
if divNode.DataAtom != atom.Div || divNode.Data != "div" {
fmt.Fprintf(os.Stderr, "FAIL: unexpected divNode DataAtom=%v Data=%q\n", divNode.DataAtom, divNode.Data)
os.Exit(1)
}
spanNode := sample.FindElementByAtom(divNode, atom.Span)
if spanNode == nil || spanNode.DataAtom != atom.Span {
fmt.Fprintf(os.Stderr, "FAIL: FindElementByAtom(atom.Span) failed\n")
os.Exit(1)
}
var customNode *html.Node
var walk func(*html.Node)
walk = func(n *html.Node) {
if n.Type == html.ElementNode && n.Data == "x-custom" {
customNode = n
return
}
for c := n.FirstChild; c != nil; c = c.NextSibling {
walk(c)
}
}
walk(doc)
if customNode == nil {
fmt.Fprintf(os.Stderr, "FAIL: custom element x-custom not found\n")
os.Exit(1)
}
if customNode.DataAtom != 0 {
fmt.Fprintf(os.Stderr, "FAIL: expected customNode.DataAtom == 0, got %v\n", customNode.DataAtom)
os.Exit(1)
}
// 5. Direct integer equality comparison between element DataAtom and atom constants
if !sample.NodeHasAtom(divNode, atom.Div) {
fmt.Fprintf(os.Stderr, "FAIL: NodeHasAtom(divNode, atom.Div) returned false\n")
os.Exit(1)
}
if sample.NodeHasAtom(divNode, atom.Span) {
fmt.Fprintf(os.Stderr, "FAIL: NodeHasAtom(divNode, atom.Span) returned true\n")
os.Exit(1)
}
fmt.Println("PASS: golang.org/x/net/html/atom.Atom contract passed")
}
오리진 시더
익명