샘플
golang.org/x/net v0.0.0-20180724234803-3673e40ba225: html.ParseFragment
검증된 샘플 — golang golang.org/x/net v0.0.0-20180724234803-3673e40ba225: html.ParseFragment. go 1.26 · linux debian/x64 · docker에서 contract를 실행해 통과했습니다.
sha256:af6b6efd44d9ee4f7e73db903974f3a3489cc020cc76bda91895a34ade8b90a2
이 네트워크가 제공하는 것은 하나입니다. 빌드되는 샘플. 샌드박스에서 돌리고 서명된 영수증을 보관합니다. 등급을 매기지 않고 무엇도 보증하지 않습니다 — 같은 코드가 당신 환경에서 빌드되는지는 측정한 적이 없습니다.
통과한 계약 영수증을 낸 서로 다른 서명 키의 수입니다. 하나면 작성자 혼자이고, 둘 이상이면 다른 사람도 빌드했다는 뜻입니다. 키는 스스로 만드는 것이고 뒤에 등록된 신원이 없으므로, 세는 것은 사람이 아니라 키입니다.
MIT-0
실행 증거
선언된 환경과 서명된 실행을 분리해 두었습니다. 이 샘플이 무엇을 어디서 실행했는지 그대로 볼 수 있습니다.
- 증거 기준
- 서명된 컨트랙트 통과
- 검증 영수증
- 1
- 빌드한 서명 키
- 1
선언된 환경
linux 24 · ubuntu · glibc 2.39 x64 go
검증 실행 환경
| 환경 | 컨트랙트 | 단계 | 실행일 |
|---|---|---|---|
| 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-17 |
케이스
HOW- 목표
- verify golang.org/x/net/html.ParseFragment in pkg:golang/golang.org/x/net@v0.0.0-20180724234803-3673e40ba225
- 심벌
-
- golang.org/x/net/html.ParseFragment
- 생성일
- 2026-10-17T20:22:09Z
컨트랙트
- html.ParseFragment with nil context parses a fragment into a root html element containing head and body
- html.ParseFragment with a body element context parses child elements directly without outer html/body wrappers
- html.ParseFragment with a table element context wraps tr elements inside an implicit tbody element
- html.ParseFragment with a select element context parses option elements and preserves their attributes
파일
- PROMPT.md
- csx.json
- go.mod
- go.sum
- 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.ParseFragment in pkg:golang/golang.org/x/net@v0.0.0-20180724234803-3673e40ba225
Kind: HOW
Use EXACTLY these public packages and versions:
- pkg:golang/golang.org/x/net@v0.0.0-20180724234803-3673e40ba225
Demonstrate these symbols/APIs:
- golang.org/x/net/html.ParseFragment
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:607ab9340b0f02210af40088d7da392d19ab82aa01a413d77c7f8f39055bea31","contract":["html.ParseFragment with nil context parses a fragment into a root html element containing head and body","html.ParseFragment with a body element context parses child elements directly without outer html/body wrappers","html.ParseFragment with a table element context wraps tr elements inside an implicit tbody element","html.ParseFragment with a select element context parses option elements and preserves their attributes"],"goal":"verify golang.org/x/net/html.ParseFragment in pkg:golang/golang.org/x/net@v0.0.0-20180724234803-3673e40ba225","kind":"HOW","packages":["pkg:golang/golang.org/x/net@v0.0.0-20180724234803-3673e40ba225"],"schemaVersion":1,"symbols":["golang.org/x/net/html.ParseFragment"]},"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.0.0-20180724234803-3673e40ba225"],"schemaVersion":1,"subject":"pkg:golang/golang.org/x/net@v0.0.0-20180724234803-3673e40ba225","symbols":["golang.org/x/net/html.ParseFragment"],"verifierAdapter":"golang@1"}
module example.com/sample
go 1.21
require golang.org/x/net v0.0.0-20180724234803-3673e40ba225
golang.org/x/net v0.0.0-20180724234803-3673e40ba225 h1:kNX+jCowfMYzvlSvJu5pQWEmyWFrBXJ3PBy10xKMXK8=
golang.org/x/net v0.0.0-20180724234803-3673e40ba225/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
{
"schemaVersion": 1,
"goal": "verify golang.org/x/net/html.ParseFragment in pkg:golang/golang.org/x/net@v0.0.0-20180724234803-3673e40ba225",
"kind": "HOW",
"packages": [
"pkg:golang/golang.org/x/net@v0.0.0-20180724234803-3673e40ba225"
],
"symbols": [
"golang.org/x/net/html.ParseFragment"
]
}
package main
import (
"fmt"
"os"
"strings"
"golang.org/x/net/html"
"golang.org/x/net/html/atom"
)
func fail(msg string, args ...any) {
fmt.Fprintf(os.Stderr, msg+"\n", args...)
os.Exit(1)
}
func main() {
// 1. ParseFragment with nil context parses into a root html element containing head and body.
nodesNil, err := html.ParseFragment(strings.NewReader("<p>hello <b>world</b></p>"), nil)
if err != nil {
fail("ParseFragment with nil context failed: %v", err)
}
if len(nodesNil) != 1 || nodesNil[0].Type != html.ElementNode || nodesNil[0].Data != "html" {
fail("expected single root html element node for nil context, got %v", nodesNil)
}
rootHTML := nodesNil[0]
if rootHTML.FirstChild == nil || rootHTML.FirstChild.Data != "head" {
fail("expected first child of html root to be head")
}
if rootHTML.LastChild == nil || rootHTML.LastChild.Data != "body" {
fail("expected last child of html root to be body")
}
bodyChild := rootHTML.LastChild.FirstChild
if bodyChild == nil || bodyChild.Type != html.ElementNode || bodyChild.Data != "p" {
fail("expected p element inside body, got %v", bodyChild)
}
// 2. ParseFragment with a body element context parses child elements directly without html/body wrappers.
bodyCtx := &html.Node{
Type: html.ElementNode,
DataAtom: atom.Body,
Data: "body",
}
nodesBody, err := html.ParseFragment(strings.NewReader("<div>alpha</div><span>beta</span>"), bodyCtx)
if err != nil {
fail("ParseFragment with body context failed: %v", err)
}
if len(nodesBody) != 2 {
fail("expected 2 nodes with body context, got %d", len(nodesBody))
}
if nodesBody[0].Type != html.ElementNode || nodesBody[0].Data != "div" || nodesBody[0].FirstChild == nil || nodesBody[0].FirstChild.Data != "alpha" {
fail("unexpected first node in body context: %+v", nodesBody[0])
}
if nodesBody[1].Type != html.ElementNode || nodesBody[1].Data != "span" || nodesBody[1].FirstChild == nil || nodesBody[1].FirstChild.Data != "beta" {
fail("unexpected second node in body context: %+v", nodesBody[1])
}
// 3. ParseFragment with a table element context wraps tr elements inside an implicit tbody element.
tableCtx := &html.Node{
Type: html.ElementNode,
DataAtom: atom.Table,
Data: "table",
}
nodesTable, err := html.ParseFragment(strings.NewReader("<tr><td>cell1</td><td>cell2</td></tr>"), tableCtx)
if err != nil {
fail("ParseFragment with table context failed: %v", err)
}
if len(nodesTable) != 1 || nodesTable[0].Type != html.ElementNode || nodesTable[0].Data != "tbody" {
fail("expected single implicit tbody element in table context, got %v", nodesTable)
}
trNode := nodesTable[0].FirstChild
if trNode == nil || trNode.Type != html.ElementNode || trNode.Data != "tr" {
fail("expected tr element inside tbody, got %v", trNode)
}
if trNode.FirstChild == nil || trNode.FirstChild.Data != "td" || trNode.LastChild == nil || trNode.LastChild.Data != "td" || trNode.FirstChild == trNode.LastChild {
fail("expected two td children inside tr")
}
// 4. ParseFragment with a select element context parses option elements and preserves their attributes.
selectCtx := &html.Node{
Type: html.ElementNode,
DataAtom: atom.Select,
Data: "select",
}
nodesSelect, err := html.ParseFragment(strings.NewReader(`<option value="one" selected>First</option><option value="two">Second</option>`), selectCtx)
if err != nil {
fail("ParseFragment with select context failed: %v", err)
}
if len(nodesSelect) != 2 {
fail("expected 2 option nodes in select context, got %d", len(nodesSelect))
}
if nodesSelect[0].Data != "option" || len(nodesSelect[0].Attr) != 2 || nodesSelect[0].Attr[0].Key != "value" || nodesSelect[0].Attr[0].Val != "one" {
fail("unexpected first option node or attributes: %+v", nodesSelect[0])
}
if nodesSelect[0].FirstChild == nil || nodesSelect[0].FirstChild.Type != html.TextNode || nodesSelect[0].FirstChild.Data != "First" {
fail("unexpected first option text child")
}
if nodesSelect[1].Data != "option" || len(nodesSelect[1].Attr) != 1 || nodesSelect[1].Attr[0].Key != "value" || nodesSelect[1].Attr[0].Val != "two" {
fail("unexpected second option node or attributes: %+v", nodesSelect[1])
}
}
오리진 시더
익명