サンプル
golang.org/x/net v0.55.0: html.EscapeString, html.Parse, html.Render
検証済みサンプル — golang golang.org/x/net v0.55.0: html.EscapeString, html.Parse, html.Render. go 1.26 · linux alpine/x64 · docker で contract を実行し、成功しました.
sha256:946934db584f1cd958ec20030fb987c6ec8e596c6f9e371f5bb3f8d8dd79ea15
このネットワークが提供するのは一つだけです。ビルドされるサンプル。サンドボックスで実行し、署名済みの受領証を保管します。等級はつけず、何も保証しません — 同じコードがあなたの環境でビルドされるかは測定していません。
合格した契約受領証を提出した異なる署名鍵の数です。1 なら作者だけ、2 以上なら他の誰かもビルドしています。鍵は自己生成で背後に登録された身元がないため、数えているのは人ではなく鍵です。
MIT-0
実行証拠
宣言された環境と署名済みの実行を分けてあります。このサンプルが何をどこで実行したかをそのまま確認できます。
- 証拠の基準
- 署名済みコントラクト合格
- 検証レシート
- 1
- ビルドした署名鍵
- 1
宣言された環境
linux 24 · ubuntu · glibc 2.39 x64 go
検証実行環境
| 環境 | コントラクト | ステージ | 実行日 |
|---|---|---|---|
| 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-27 |
ケース
HOW- ゴール
- verify golang.org/x/net/html Parse, Render, and EscapeString in pkg:golang/golang.org/x/net@v0.55.0
- パッケージ
- シンボル
-
- golang.org/x/net/html.EscapeString
- golang.org/x/net/html.Parse
- golang.org/x/net/html.Render
- 作成日
- 2026-08-27T15:38:50Z
コントラクト
- html.EscapeString escapes special characters like ampersands, angle brackets, and quotes for safe HTML insertion
- html.Parse parses an HTML document into a DocumentNode tree with correct node hierarchy and attributes
- html.Render serializes an HTML node tree back into formatted HTML written to an io.Writer
ファイル
- 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 Parse, Render, and EscapeString in pkg:golang/golang.org/x/net@v0.55.0
Kind: HOW
Use EXACTLY these public packages and versions:
- pkg:golang/golang.org/x/net@v0.55.0
Demonstrate these symbols/APIs:
- golang.org/x/net/html.EscapeString
- golang.org/x/net/html.Parse
- golang.org/x/net/html.Render
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:b9902c1fa57d5fe59cf642b2e606b34c4c7e7d80f39cdf996a3df429f5b26b6c","contract":["html.EscapeString escapes special characters like ampersands, angle brackets, and quotes for safe HTML insertion","html.Parse parses an HTML document into a DocumentNode tree with correct node hierarchy and attributes","html.Render serializes an HTML node tree back into formatted HTML written to an io.Writer"],"goal":"verify golang.org/x/net/html Parse, Render, and EscapeString in pkg:golang/golang.org/x/net@v0.55.0","kind":"HOW","packages":["pkg:golang/golang.org/x/net@v0.55.0"],"schemaVersion":1,"symbols":["golang.org/x/net/html.EscapeString","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.55.0"],"schemaVersion":1,"subject":"pkg:golang/golang.org/x/net@v0.55.0","symbols":["golang.org/x/net/html.EscapeString","golang.org/x/net/html.Parse","golang.org/x/net/html.Render"],"verifierAdapter":"golang@1"}
module example.com/sample
go 1.25.0
require golang.org/x/net v0.55.0
golang.org/x/net v0.55.0 h1:bcvxaJn3e1U6InsFWt1JUq1aSjnRxLzT2rtD2KfkDF8=
golang.org/x/net v0.55.0/go.mod h1:L5U2KuzuOe1lY7Z+aWVIKK6qEeJXnXV9yzGA+WCHJww=
package main
import (
"bytes"
"fmt"
"log"
"strings"
"golang.org/x/net/html"
)
func main() {
rawHTML := `<div class="container"><p>Hello & welcome <friends>!</p></div>`
rawText := "Tom & Jerry <cartoon>"
escaped := html.EscapeString(rawText)
fmt.Printf("Escaped: %s\n", escaped)
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())
}
{
"schemaVersion": 1,
"goal": "verify golang.org/x/net/html Parse, Render, and EscapeString in pkg:golang/golang.org/x/net@v0.55.0",
"kind": "HOW",
"packages": [
"pkg:golang/golang.org/x/net@v0.55.0"
],
"symbols": [
"golang.org/x/net/html.EscapeString",
"golang.org/x/net/html.Parse",
"golang.org/x/net/html.Render"
]
}
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 like ampersands, angle brackets, and quotes for safe HTML insertion
unescaped := `<div id="test">& 'hello' "world"</div>`
escaped := html.EscapeString(unescaped)
expectedEscaped := `<div id="test">& 'hello' "world"</div>`
if escaped != expectedEscaped {
fmt.Fprintf(os.Stderr, "assertion 1 failed: expected %q, got %q\n", expectedEscaped, escaped)
os.Exit(1)
}
// Assertion 2: html.Parse parses an HTML document into a DocumentNode tree with correct node hierarchy and attributes
input := `<!DOCTYPE html><html><head><title>Test Page</title></head><body><div class="box" id="main-box"><p>Sample Text</p></div></body></html>`
doc, err := html.Parse(strings.NewReader(input))
if err != nil {
fmt.Fprintf(os.Stderr, "assertion 2 failed: html.Parse error: %v\n", err)
os.Exit(1)
}
if doc == nil || doc.Type != html.DocumentNode {
fmt.Fprintf(os.Stderr, "assertion 2 failed: expected DocumentNode, got %v\n", doc)
os.Exit(1)
}
var findFirstByAtom func(*html.Node, atom.Atom) *html.Node
findFirstByAtom = func(n *html.Node, a atom.Atom) *html.Node {
if n == nil {
return nil
}
if n.DataAtom == a {
return n
}
for c := n.FirstChild; c != nil; c = c.NextSibling {
if res := findFirstByAtom(c, a); res != nil {
return res
}
}
return nil
}
divNode := findFirstByAtom(doc, atom.Div)
if divNode == nil {
fmt.Fprintf(os.Stderr, "assertion 2 failed: div element not found\n")
os.Exit(1)
}
var classVal, idVal string
for _, attr := range divNode.Attr {
if attr.Key == "class" {
classVal = attr.Val
}
if attr.Key == "id" {
idVal = attr.Val
}
}
if classVal != "box" || idVal != "main-box" {
fmt.Fprintf(os.Stderr, "assertion 2 failed: expected class='box' id='main-box', got class=%q id=%q\n", classVal, idVal)
os.Exit(1)
}
pNode := findFirstByAtom(divNode, atom.P)
if pNode == nil || pNode.FirstChild == nil || pNode.FirstChild.Type != html.TextNode || pNode.FirstChild.Data != "Sample Text" {
fmt.Fprintf(os.Stderr, "assertion 2 failed: expected p text 'Sample Text', got %+v\n", pNode)
os.Exit(1)
}
// Assertion 3: html.Render serializes an HTML node tree back into formatted HTML written to an io.Writer
var buf bytes.Buffer
if err := html.Render(&buf, divNode); err != nil {
fmt.Fprintf(os.Stderr, "assertion 3 failed: html.Render error: %v\n", err)
os.Exit(1)
}
rendered := buf.String()
expectedSub := `<div class="box" id="main-box"><p>Sample Text</p></div>`
if !strings.Contains(rendered, expectedSub) {
fmt.Fprintf(os.Stderr, "assertion 3 failed: rendered HTML %q does not contain %q\n", rendered, expectedSub)
os.Exit(1)
}
fmt.Println("All contract assertions passed.")
}
オリジンシーダー
匿名