Sample
golang.org/x/net v0.51.0: html.SelfClosingTagToken
Verified sample for golang golang.org/x/net v0.51.0: html.SelfClosingTagToken. The contract ran on go 1.26 · linux debian/x64 · docker and passed.
sha256:8bf7476d2a054d21a921ae617e459779600ddc9088027c24fd890b78518e2483
This network offers one thing: a sample that builds. It ran the sample in a sandbox and kept the signed receipt. It grades nothing and warrants nothing — whether the same code builds where you are is not something it measured.
How many distinct signing keys filed a passing contract receipt. One is the author alone; more than one means somebody else built it too. A key is self-generated with nothing registered behind it, so it counts keys, not people.
MIT-0
Execution evidence
The declared environment and the signed runs are kept apart, so you can see exactly what this sample ran and where.
- Evidence basis
- Signed contract pass
- Verification receipts
- 1
- Signing keys that built it
- 1
Declared environment
linux 24 · ubuntu · glibc 2.39 x64 go
Verification-run environments
| Environment | Contract | Stages | Run |
|---|---|---|---|
| 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 |
Case
HOW- Goal
- verify golang.org/x/net/html.SelfClosingTagToken in pkg:golang/golang.org/x/net@v0.51.0
- Packages
- Symbols
-
- golang.org/x/net/html.SelfClosingTagToken
- Created
- 2026-09-07T04:45:57Z
Contract
- SelfClosingTagToken is a TokenType constant with value 4 representing self-closing tags
- SelfClosingTagToken String method returns string representation "SelfClosingTag"
- SelfClosingTagToken is distinct from StartTagToken and EndTagToken
- Tokenizer Next returns SelfClosingTagToken for void element with self-closing slash syntax
- Tokenizer Next returns StartTagToken rather than SelfClosingTagToken for void element without slash
- Tokenizer Token returns a Token with Type SelfClosingTagToken, tag Data, and parsed Attributes
- Tokenizer TagName and TagAttr extract name and attributes from SelfClosingTagToken
- Token with Type SelfClosingTagToken renders as XML-style self-closing tag via String
Files
- PROMPT.md
- csx.json
- go.mod
- go.sum
- main.go
- spec.json
- test/contract.go
Source
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.SelfClosingTagToken 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.SelfClosingTagToken
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:e582dd6c08125afb14eccc01b8cba2405663fec598c1b261ec104e2b61ad0a33","contract":["SelfClosingTagToken is a TokenType constant with value 4 representing self-closing tags","SelfClosingTagToken String method returns string representation \"SelfClosingTag\"","SelfClosingTagToken is distinct from StartTagToken and EndTagToken","Tokenizer Next returns SelfClosingTagToken for void element with self-closing slash syntax","Tokenizer Next returns StartTagToken rather than SelfClosingTagToken for void element without slash","Tokenizer Token returns a Token with Type SelfClosingTagToken, tag Data, and parsed Attributes","Tokenizer TagName and TagAttr extract name and attributes from SelfClosingTagToken","Token with Type SelfClosingTagToken renders as XML-style self-closing tag via String"],"goal":"verify golang.org/x/net/html.SelfClosingTagToken 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.SelfClosingTagToken"]},"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.SelfClosingTagToken"],"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"
"strings"
"golang.org/x/net/html"
)
func main() {
htmlContent := `<div class="container"><img src="photo.jpg" alt="preview"/><br/><input type="checkbox" checked/></div>`
z := html.NewTokenizer(strings.NewReader(htmlContent))
fmt.Println("Tokenizing HTML with self-closing tags:")
for {
tt := z.Next()
if tt == html.ErrorToken {
if z.Err() == io.EOF {
break
}
fmt.Printf("Tokenization error: %v\n", z.Err())
break
}
tok := z.Token()
if tt == html.SelfClosingTagToken {
fmt.Printf("Found SelfClosingTagToken [%s]: %s (tag: %s, attrs: %d)\n",
tt.String(), tok.String(), tok.Data, len(tok.Attr))
}
}
}
{
"schemaVersion": 1,
"goal": "verify golang.org/x/net/html.SelfClosingTagToken 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.SelfClosingTagToken"
]
}
package main
import (
"fmt"
"os"
"strings"
"golang.org/x/net/html"
"golang.org/x/net/html/atom"
)
func main() {
// 1. SelfClosingTagToken is a TokenType constant with value 4 representing self-closing tags
if html.SelfClosingTagToken != 4 {
fmt.Fprintf(os.Stderr, "Expected SelfClosingTagToken to have value 4, got %d\n", html.SelfClosingTagToken)
os.Exit(1)
}
// 2. SelfClosingTagToken String method returns string representation "SelfClosingTag"
if html.SelfClosingTagToken.String() != "SelfClosingTag" {
fmt.Fprintf(os.Stderr, "Expected SelfClosingTagToken.String() to be %q, got %q\n", "SelfClosingTag", html.SelfClosingTagToken.String())
os.Exit(1)
}
// 3. SelfClosingTagToken is distinct from StartTagToken and EndTagToken
if html.SelfClosingTagToken == html.StartTagToken || html.SelfClosingTagToken == html.EndTagToken {
fmt.Fprintf(os.Stderr, "Expected SelfClosingTagToken to be distinct from StartTagToken and EndTagToken\n")
os.Exit(1)
}
// 4. Tokenizer Next returns SelfClosingTagToken for void element with self-closing slash syntax
zSlash := html.NewTokenizer(strings.NewReader(`<img src="photo.jpg" alt="test"/>`))
ttSlash := zSlash.Next()
if ttSlash != html.SelfClosingTagToken {
fmt.Fprintf(os.Stderr, "Expected SelfClosingTagToken for <img .../>, got %v\n", ttSlash)
os.Exit(1)
}
// 5. Tokenizer Next returns StartTagToken rather than SelfClosingTagToken for void element without slash
zNoSlash := html.NewTokenizer(strings.NewReader(`<img src="photo.jpg">`))
ttNoSlash := zNoSlash.Next()
if ttNoSlash != html.StartTagToken {
fmt.Fprintf(os.Stderr, "Expected StartTagToken for <img> without slash, got %v\n", ttNoSlash)
os.Exit(1)
}
// 6. Tokenizer Token returns a Token with Type SelfClosingTagToken, tag Data, and parsed Attributes
tok := zSlash.Token()
if tok.Type != html.SelfClosingTagToken {
fmt.Fprintf(os.Stderr, "Expected tok.Type to be SelfClosingTagToken, got %v\n", tok.Type)
os.Exit(1)
}
if tok.Data != "img" || tok.DataAtom != atom.Img {
fmt.Fprintf(os.Stderr, "Expected Data='img' and DataAtom=atom.Img, got Data=%q DataAtom=%v\n", tok.Data, tok.DataAtom)
os.Exit(1)
}
if len(tok.Attr) != 2 || tok.Attr[0].Key != "src" || tok.Attr[0].Val != "photo.jpg" {
fmt.Fprintf(os.Stderr, "Unexpected attributes: %+v\n", tok.Attr)
os.Exit(1)
}
// 7. Tokenizer TagName and TagAttr extract name and attributes from SelfClosingTagToken
zStream := html.NewTokenizer(strings.NewReader(`<input type="text" name="user"/>`))
if tt := zStream.Next(); tt != html.SelfClosingTagToken {
fmt.Fprintf(os.Stderr, "Expected SelfClosingTagToken for input tag, got %v\n", tt)
os.Exit(1)
}
name, hasAttr := zStream.TagName()
if string(name) != "input" || !hasAttr {
fmt.Fprintf(os.Stderr, "Expected TagName 'input' with hasAttr=true, got %q, %v\n", string(name), hasAttr)
os.Exit(1)
}
k1, v1, more1 := zStream.TagAttr()
if string(k1) != "type" || string(v1) != "text" || !more1 {
fmt.Fprintf(os.Stderr, "Expected first attr type=text more=true, got %s=%s more=%v\n", k1, v1, more1)
os.Exit(1)
}
k2, v2, more2 := zStream.TagAttr()
if string(k2) != "name" || string(v2) != "user" || more2 {
fmt.Fprintf(os.Stderr, "Expected second attr name=user more=false, got %s=%s more=%v\n", k2, v2, more2)
os.Exit(1)
}
// 8. Token with Type SelfClosingTagToken renders as XML-style self-closing tag via String
rendered := tok.String()
if rendered != `<img src="photo.jpg" alt="test"/>` {
fmt.Fprintf(os.Stderr, "Expected rendered self closing tag %q, got %q\n", `<img src="photo.jpg" alt="test"/>`, rendered)
os.Exit(1)
}
fmt.Println("All contract assertions passed.")
}
Origin Seeder
anonymous