Sample
golang.org/x/net v0.51.0: html.EndTagToken
Verified sample for golang golang.org/x/net v0.51.0: html.EndTagToken. The contract ran on go 1.26 · linux debian/x64 · docker and passed.
sha256:930f527cc803b9bb656f32a4affc1438d614ad286a25e75d2e4970835a055794
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.EndTagToken in pkg:golang/golang.org/x/net@v0.51.0
- Packages
- Symbols
-
- golang.org/x/net/html.EndTagToken
- Created
- 2026-09-07T04:11:55Z
Contract
- html.EndTagToken is a TokenType constant with string representation "EndTag"
- html.EndTagToken is distinct from StartTagToken, SelfClosingTagToken, and TextToken
- html.NewTokenizer emits html.EndTagToken when encountering closing tags
- html.Token with html.EndTagToken serializes to </tag> string representation
- Tokenizer.TagName returns tag name and no attributes for html.EndTagToken
Files
- PROMPT.md
- csx.json
- go.mod
- go.sum
- sample.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.EndTagToken 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.EndTagToken
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:95b16ea77936d63733af6eda1dc8c708d4d0506eac8805526c14af50d630cc6b","contract":["html.EndTagToken is a TokenType constant with string representation \"EndTag\"","html.EndTagToken is distinct from StartTagToken, SelfClosingTagToken, and TextToken","html.NewTokenizer emits html.EndTagToken when encountering closing tags","html.Token with html.EndTagToken serializes to \u003c/tag\u003e string representation","Tokenizer.TagName returns tag name and no attributes for html.EndTagToken"],"goal":"verify golang.org/x/net/html.EndTagToken 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.EndTagToken"]},"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.EndTagToken"],"verifierAdapter":"golang@1"}
module 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 sample
import (
"fmt"
"io"
"strings"
"golang.org/x/net/html"
)
// IsEndTag checks whether the given TokenType is an EndTagToken.
func IsEndTag(tt html.TokenType) bool {
return tt == html.EndTagToken
}
// MakeEndTagToken constructs an html.Token with Type html.EndTagToken and the specified tag name.
func MakeEndTagToken(name string) html.Token {
return html.Token{
Type: html.EndTagToken,
Data: name,
}
}
// ExtractEndTags parses HTML from the reader and collects all closing tag names encountered.
func ExtractEndTags(r io.Reader) ([]string, error) {
z := html.NewTokenizer(r)
var endTags []string
for {
tt := z.Next()
switch tt {
case html.ErrorToken:
err := z.Err()
if err == io.EOF {
return endTags, nil
}
return nil, fmt.Errorf("tokenizer error: %w", err)
case html.EndTagToken:
name, _ := z.TagName()
endTags = append(endTags, string(name))
}
}
}
// ValidateTagPairs verifies that opening tags are properly closed in nesting order.
func ValidateTagPairs(htmlStr string) (bool, error) {
z := html.NewTokenizer(strings.NewReader(htmlStr))
var stack []string
for {
tt := z.Next()
switch tt {
case html.ErrorToken:
err := z.Err()
if err == io.EOF {
return len(stack) == 0, nil
}
return false, fmt.Errorf("tokenizer error: %w", err)
case html.StartTagToken:
name, _ := z.TagName()
stack = append(stack, string(name))
case html.EndTagToken:
name, _ := z.TagName()
tagName := string(name)
if len(stack) == 0 || stack[len(stack)-1] != tagName {
return false, nil
}
stack = stack[:len(stack)-1]
}
}
}
{
"schemaVersion": 1,
"goal": "verify golang.org/x/net/html.EndTagToken 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.EndTagToken"
]
}
package main
import (
"fmt"
"os"
"reflect"
"strings"
"golang.org/x/net/html"
"sample"
)
func main() {
// Assertion 1: html.EndTagToken is a TokenType constant with string representation "EndTag"
var tt html.TokenType = html.EndTagToken
if tt.String() != "EndTag" {
fmt.Fprintf(os.Stderr, "FAIL: Assertion 1 failed: expected 'EndTag', got %q\n", tt.String())
os.Exit(1)
}
if !sample.IsEndTag(html.EndTagToken) {
fmt.Fprintf(os.Stderr, "FAIL: Assertion 1 failed: sample.IsEndTag returned false for EndTagToken\n")
os.Exit(1)
}
// Assertion 2: html.EndTagToken is distinct from StartTagToken, SelfClosingTagToken, and TextToken
if html.EndTagToken == html.StartTagToken {
fmt.Fprintf(os.Stderr, "FAIL: Assertion 2 failed: EndTagToken equals StartTagToken\n")
os.Exit(1)
}
if html.EndTagToken == html.SelfClosingTagToken {
fmt.Fprintf(os.Stderr, "FAIL: Assertion 2 failed: EndTagToken equals SelfClosingTagToken\n")
os.Exit(1)
}
if html.EndTagToken == html.TextToken {
fmt.Fprintf(os.Stderr, "FAIL: Assertion 2 failed: EndTagToken equals TextToken\n")
os.Exit(1)
}
if sample.IsEndTag(html.StartTagToken) || sample.IsEndTag(html.TextToken) {
fmt.Fprintf(os.Stderr, "FAIL: Assertion 2 failed: sample.IsEndTag returned true for non-EndTag\n")
os.Exit(1)
}
// Assertion 3: html.NewTokenizer emits html.EndTagToken when encountering closing tags
htmlSnippet := `<div class="box"><p>Hello World</p><span>Item</span></div>`
endTags, err := sample.ExtractEndTags(strings.NewReader(htmlSnippet))
if err != nil {
fmt.Fprintf(os.Stderr, "FAIL: Assertion 3 failed to extract end tags: %v\n", err)
os.Exit(1)
}
expectedEndTags := []string{"p", "span", "div"}
if !reflect.DeepEqual(endTags, expectedEndTags) {
fmt.Fprintf(os.Stderr, "FAIL: Assertion 3 failed: expected %v, got %v\n", expectedEndTags, endTags)
os.Exit(1)
}
// Assertion 4: html.Token with html.EndTagToken serializes to </tag> string representation
endToken := sample.MakeEndTagToken("div")
if endToken.Type != html.EndTagToken {
fmt.Fprintf(os.Stderr, "FAIL: Assertion 4 failed: expected token type EndTagToken, got %v\n", endToken.Type)
os.Exit(1)
}
if endToken.String() != "</div>" {
fmt.Fprintf(os.Stderr, "FAIL: Assertion 4 failed: expected '</div>', got %q\n", endToken.String())
os.Exit(1)
}
customEndToken := html.Token{
Type: html.EndTagToken,
Data: "section",
}
if customEndToken.String() != "</section>" {
fmt.Fprintf(os.Stderr, "FAIL: Assertion 4 failed: expected '</section>', got %q\n", customEndToken.String())
os.Exit(1)
}
// Assertion 5: Tokenizer.TagName returns tag name and no attributes for html.EndTagToken
z := html.NewTokenizer(strings.NewReader("<main></main>"))
foundEndTag := false
for {
tokenType := z.Next()
if tokenType == html.ErrorToken {
break
}
if tokenType == html.EndTagToken {
foundEndTag = true
name, hasAttr := z.TagName()
if string(name) != "main" {
fmt.Fprintf(os.Stderr, "FAIL: Assertion 5 failed: expected tag name 'main', got %q\n", string(name))
os.Exit(1)
}
if hasAttr {
fmt.Fprintf(os.Stderr, "FAIL: Assertion 5 failed: expected hasAttr=false for EndTagToken\n")
os.Exit(1)
}
raw := string(z.Raw())
if raw != "</main>" {
fmt.Fprintf(os.Stderr, "FAIL: Assertion 5 failed: expected raw '</main>', got %q\n", raw)
os.Exit(1)
}
}
}
if !foundEndTag {
fmt.Fprintf(os.Stderr, "FAIL: Assertion 5 failed: EndTagToken was not encountered in tokenizer\n")
os.Exit(1)
}
// Validation helper verification using EndTagToken matching
valid, err := sample.ValidateTagPairs("<div><p><span>nested</span></p></div>")
if err != nil || !valid {
fmt.Fprintf(os.Stderr, "FAIL: ValidateTagPairs failed for valid HTML: valid=%v, err=%v\n", valid, err)
os.Exit(1)
}
invalid, err := sample.ValidateTagPairs("<div><p>mismatched</div></p>")
if err != nil || invalid {
fmt.Fprintf(os.Stderr, "FAIL: ValidateTagPairs failed for mismatched tags: invalid=%v, err=%v\n", invalid, err)
os.Exit(1)
}
fmt.Println("PASS: all golang.org/x/net/html.EndTagToken contract assertions passed")
}
Origin Seeder
anonymous