Exemplo
golang.org/x/net v0.41.0: html.TextNode
Amostra verificada para golang golang.org/x/net v0.41.0: html.TextNode. O contrato rodou em go 1.26 · linux debian/x64 · docker e passou.
sha256:18b0482dcc3081344ec35a802a476e9d03fdba9125fd793f848b85e6bde80e7c
Esta rede oferece uma coisa: uma amostra que compila. Ela a executou em um sandbox e guardou o recibo assinado. Não classifica nem garante nada — se o mesmo código compila onde você está, ela não mediu.
Quantas chaves de assinatura distintas enviaram um recibo de contrato aprovado. Uma é só o autor; mais de uma significa que outra pessoa também o compilou. Uma chave é gerada por conta própria e não tem identidade registrada por trás, então conta chaves, não pessoas.
MIT-0
Evidência de execução
O ambiente declarado e as execuções assinadas ficam separados, para você ver exatamente o que esta amostra executou e onde.
- Base da evidência
- Contrato assinado aprovado
- Recibos de verificação
- 1
- Chaves de assinatura que o compilaram
- 1
Ambiente declarado
linux 24 · ubuntu · glibc 2.39 x64 go
Ambientes das execuções de verificação
| Ambiente | Contrato | Etapas | Execução |
|---|---|---|---|
| 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-14 |
Caso
HOW- Objetivo
- verify golang.org/x/net/html.TextNode in pkg:golang/golang.org/x/net@v0.41.0
- Pacotes
- Símbolos
-
- golang.org/x/net/html.TextNode
- Criado
- 2026-10-14T20:38:00Z
Contrato
- html.TextNode is a distinct html.NodeType constant
- NewTextNode creates an html.Node with Type html.TextNode and the given Data
- IsTextNode returns true only for non-nil nodes with Type html.TextNode
- CollectText extracts text content from html.TextNode nodes in parsed HTML
- html.Render escapes HTML special characters in html.TextNode Data
Arquivos
- PROMPT.md
- csx.json
- go.mod
- go.sum
- spec.json
- test/contract.go
- textnode.go
Código-fonte
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.TextNode 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.TextNode
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:c3077aea6e7dca04d83b8e60e9762f3c94897d2206f06d582584c214526cde59","contract":["html.TextNode is a distinct html.NodeType constant","NewTextNode creates an html.Node with Type html.TextNode and the given Data","IsTextNode returns true only for non-nil nodes with Type html.TextNode","CollectText extracts text content from html.TextNode nodes in parsed HTML","html.Render escapes HTML special characters in html.TextNode Data"],"goal":"verify golang.org/x/net/html.TextNode 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.TextNode"]},"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.TextNode"],"verifierAdapter":"golang@1"}
module sample
go 1.24.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.TextNode 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.TextNode"
]
}
package main
import (
"fmt"
"os"
"strings"
"golang.org/x/net/html"
"sample"
)
func main() {
// 1. html.TextNode is a distinct html.NodeType constant
var nt html.NodeType = html.TextNode
if nt != html.TextNode || nt == html.ElementNode || nt == html.DocumentNode || nt == html.CommentNode {
fmt.Fprintf(os.Stderr, "unexpected html.TextNode constant value: %v\n", nt)
os.Exit(1)
}
// 2. NewTextNode creates an html.Node with Type html.TextNode and the given Data
tn := sample.NewTextNode("sample text")
if tn == nil || tn.Type != html.TextNode || tn.Data != "sample text" {
fmt.Fprintf(os.Stderr, "NewTextNode failed: %+v\n", tn)
os.Exit(1)
}
// 3. IsTextNode returns true only for non-nil nodes with Type html.TextNode
if !sample.IsTextNode(tn) {
fmt.Fprintf(os.Stderr, "IsTextNode returned false for TextNode\n")
os.Exit(1)
}
if sample.IsTextNode(&html.Node{Type: html.ElementNode, Data: "p"}) || sample.IsTextNode(nil) {
fmt.Fprintf(os.Stderr, "IsTextNode returned true for non-TextNode\n")
os.Exit(1)
}
// 4. CollectText extracts text content from html.TextNode nodes in parsed HTML
doc, err := html.Parse(strings.NewReader("<article><h1>Title</h1><p>Body <b>bold</b></p></article>"))
if err != nil {
fmt.Fprintf(os.Stderr, "html.Parse failed: %v\n", err)
os.Exit(1)
}
if got := sample.CollectText(doc); got != "TitleBody bold" {
fmt.Fprintf(os.Stderr, "CollectText got %q, want %q\n", got, "TitleBody bold")
os.Exit(1)
}
// 5. html.Render escapes HTML special characters in html.TextNode Data
escaped, err := sample.RenderTextNode(sample.NewTextNode("<b>a & b</b>"))
if err != nil {
fmt.Fprintf(os.Stderr, "RenderTextNode failed: %v\n", err)
os.Exit(1)
}
if want := "<b>a & b</b>"; escaped != want {
fmt.Fprintf(os.Stderr, "RenderTextNode got %q, want %q\n", escaped, want)
os.Exit(1)
}
}
package sample
import (
"bytes"
"strings"
"golang.org/x/net/html"
)
// NewTextNode constructs an html.Node with Type set to html.TextNode.
func NewTextNode(text string) *html.Node {
return &html.Node{
Type: html.TextNode,
Data: text,
}
}
// IsTextNode reports whether n is a non-nil html.Node of type html.TextNode.
func IsTextNode(n *html.Node) bool {
return n != nil && n.Type == html.TextNode
}
// CollectText traverses the node subtree and concatenates Data from all html.TextNode nodes.
func CollectText(root *html.Node) string {
if root == nil {
return ""
}
var b strings.Builder
var walk func(*html.Node)
walk = func(n *html.Node) {
if n.Type == html.TextNode {
b.WriteString(n.Data)
}
for c := n.FirstChild; c != nil; c = c.NextSibling {
walk(c)
}
}
walk(root)
return b.String()
}
// RenderTextNode renders an html.Node into HTML string output.
func RenderTextNode(n *html.Node) (string, error) {
var buf bytes.Buffer
if err := html.Render(&buf, n); err != nil {
return "", err
}
return buf.String(), nil
}
Seeder de origem
anônimo