Sample
golang.org/x/net v0.24.0: html.EscapeString, html.UnescapeString, html.Parse
Verified sample for golang golang.org/x/net v0.24.0: html.EscapeString, html.UnescapeString, html.Parse. The contract ran on go 1.26 · linux alpine/x64 …
sha256:c0057ed72fd15ff9bb0207d28ba4694103b346af39b11da05088620c2837a54b
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 alpine/x64 · docker ed25519:c1973797be207ac4 | PASS | compile:SKIPPED · contract:PASS · load:PASS · resolve:PASS CONTAINER_RUN · golang@1golang:1.26-alpine@sha256:28d89ee9cc0f… |
2026-08-28 |
Case
HOW- Goal
- verify pkg:golang/golang.org/x/net@v0.24.0
- Packages
- Symbols
-
- golang.org/x/net/html.EscapeString
- golang.org/x/net/html.UnescapeString
- golang.org/x/net/html.Parse
- golang.org/x/net/html.Render
- Created
- 2026-08-28T08:59:15Z
Contract
- html.EscapeString escapes special characters for safe HTML inclusion
- html.UnescapeString unescapes HTML entities back to plain text
- html.Parse parses an HTML document into a Node tree
- html.Render serializes an HTML Node tree back into formatted HTML written to an io.Writer
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 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
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:155c54b729d254d6467dbc3eae41f943e3107749022c03d671a41b46f61bb124","contract":["html.EscapeString escapes special characters for safe HTML inclusion","html.UnescapeString unescapes HTML entities back to plain text","html.Parse parses an HTML document into a Node tree","html.Render serializes an HTML Node tree back into formatted HTML written to an io.Writer"],"goal":"verify 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.EscapeString","golang.org/x/net/html.UnescapeString","golang.org/x/net/html.Parse","golang.org/x/net/html.Render"]},"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.24.0"],"schemaVersion":1,"subject":"pkg:golang/golang.org/x/net@v0.24.0","symbols":["golang.org/x/net/html.EscapeString","golang.org/x/net/html.UnescapeString","golang.org/x/net/html.Parse","golang.org/x/net/html.Render"],"verifierAdapter":"golang@1"}
module example.com/sample
go 1.22.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"
"log"
"strings"
"golang.org/x/net/html"
)
func main() {
rawHTML := `<!DOCTYPE html><html><head><title>Sample</title></head><body><p class="greeting">Hello & welcome to CodeSampleX!</p></body></html>`
doc, err := html.Parse(strings.NewReader(rawHTML))
if err != nil {
log.Fatalf("failed to parse HTML: %v", err)
}
var buf bytes.Buffer
if err := html.Render(&buf, doc); err != nil {
log.Fatalf("failed to render HTML: %v", err)
}
fmt.Printf("Rendered HTML:\n%s\n", buf.String())
raw := `<script>alert("hello & welcome")</script>`
escaped := html.EscapeString(raw)
fmt.Printf("Escaped: %s\n", escaped)
unescaped := html.UnescapeString(escaped)
fmt.Printf("Unescaped: %s\n", unescaped)
}
{
"schemaVersion": 1,
"goal": "verify pkg:golang/golang.org/x/net@v0.24.0",
"kind": "HOW",
"packages": [
"pkg:golang/golang.org/x/net@v0.24.0"
]
}
package main
import (
"bytes"
"fmt"
"os"
"strings"
"golang.org/x/net/html"
"golang.org/x/net/html/atom"
)
func main() {
// Assertion 1: html.EscapeString escapes special characters for safe HTML inclusion
{
input := `<div class="test" data-val='1 & 2'>Hello & Welcome</div>`
escaped := html.EscapeString(input)
expected := `<div class="test" data-val='1 & 2'>Hello & Welcome</div>`
if escaped != expected {
fmt.Fprintf(os.Stderr, "assertion 1 failed: expected %q, got %q\n", expected, escaped)
os.Exit(1)
}
}
// Assertion 2: html.UnescapeString unescapes HTML entities back to plain text
{
input := `<div class="test">Hello & Welcome</div>`
unescaped := html.UnescapeString(input)
expected := `<div class="test">Hello & Welcome</div>`
if unescaped != expected {
fmt.Fprintf(os.Stderr, "assertion 2 failed: expected %q, got %q\n", expected, unescaped)
os.Exit(1)
}
}
// Assertion 3: html.Parse parses an HTML document into a Node tree
{
src := `<!DOCTYPE html><html><head><title>Test Page</title></head><body><h1>Header</h1><p id="content">Body paragraph</p></body></html>`
doc, err := html.Parse(strings.NewReader(src))
if err != nil {
fmt.Fprintf(os.Stderr, "assertion 3 failed: html.Parse returned error: %v\n", err)
os.Exit(1)
}
if doc == nil || doc.Type != html.DocumentNode {
fmt.Fprintf(os.Stderr, "assertion 3 failed: expected root DocumentNode, got %v\n", doc)
os.Exit(1)
}
var foundH1, foundP bool
var crawler func(*html.Node)
crawler = func(n *html.Node) {
if n.Type == html.ElementNode {
if n.DataAtom == atom.H1 || n.Data == "h1" {
if n.FirstChild != nil && n.FirstChild.Data == "Header" {
foundH1 = true
}
}
if n.DataAtom == atom.P || n.Data == "p" {
for _, attr := range n.Attr {
if attr.Key == "id" && attr.Val == "content" {
if n.FirstChild != nil && n.FirstChild.Data == "Body paragraph" {
foundP = true
}
}
}
}
}
for c := n.FirstChild; c != nil; c = c.NextSibling {
crawler(c)
}
}
crawler(doc)
if !foundH1 || !foundP {
fmt.Fprintf(os.Stderr, "assertion 3 failed: DOM structure not parsed correctly: foundH1=%v, foundP=%v\n", foundH1, foundP)
os.Exit(1)
}
}
// Assertion 4: html.Render serializes an HTML Node tree back into formatted HTML written to an io.Writer
{
src := `<!DOCTYPE html><html><head><title>Test Page</title></head><body><h1>Header</h1><p id="content">Body paragraph</p></body></html>`
doc, err := html.Parse(strings.NewReader(src))
if err != nil {
fmt.Fprintf(os.Stderr, "assertion 4 failed: parse error: %v\n", err)
os.Exit(1)
}
var buf bytes.Buffer
if err := html.Render(&buf, doc); err != nil {
fmt.Fprintf(os.Stderr, "assertion 4 failed: html.Render returned error: %v\n", err)
os.Exit(1)
}
rendered := buf.String()
if !strings.Contains(rendered, "<title>Test Page</title>") || !strings.Contains(rendered, `id="content"`) {
fmt.Fprintf(os.Stderr, "assertion 4 failed: rendered HTML missing expected content: %s\n", rendered)
os.Exit(1)
}
}
fmt.Println("All contract assertions passed.")
}
Origin Seeder
anonymous