샘플
golang.org/x/net v0.47.0: html.Attribute
검증된 샘플 — golang golang.org/x/net v0.47.0: html.Attribute. go 1.26 · linux debian/x64 · docker에서 contract를 실행해 통과했습니다: Attribute struct fields Namespace, Key…
sha256:052c1714164ae4d1d8668ee94ed1fa9d4f7269491c42ed79651dfcd5e8623374
이 네트워크가 제공하는 것은 하나입니다. 빌드되는 샘플. 샌드박스에서 돌리고 서명된 영수증을 보관합니다. 등급을 매기지 않고 무엇도 보증하지 않습니다 — 같은 코드가 당신 환경에서 빌드되는지는 측정한 적이 없습니다.
통과한 계약 영수증을 낸 서로 다른 서명 키의 수입니다. 하나면 작성자 혼자이고, 둘 이상이면 다른 사람도 빌드했다는 뜻입니다. 키는 스스로 만드는 것이고 뒤에 등록된 신원이 없으므로, 세는 것은 사람이 아니라 키입니다.
MIT-0
실행 증거
선언된 환경과 서명된 실행을 분리해 두었습니다. 이 샘플이 무엇을 어디서 실행했는지 그대로 볼 수 있습니다.
- 증거 기준
- 서명된 컨트랙트 통과
- 검증 영수증
- 1
- 빌드한 서명 키
- 1
선언된 환경
go 1.26 linux 24 · ubuntu · glibc 2.39 x64 go 1.26 go go 1
검증 실행 환경
| 환경 | 컨트랙트 | 단계 | 실행일 |
|---|---|---|---|
| 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-10 |
케이스
HOW- 목표
- verify golang.org/x/net/html.Attribute in pkg:golang/golang.org/x/net@v0.47.0
- 심벌
-
- golang.org/x/net/html.Attribute
- 환경
- go 1.26.6
- 생성일
- 2026-10-10T22:35:36Z
컨트랙트
- Attribute struct fields Namespace, Key, and Val represent HTML element attributes
- html.Parse extracts element attributes into html.Node.Attr as a slice of html.Attribute
- html.Render serializes html.Node with html.Attribute slice into valid HTML attribute syntax
- Attribute supports namespaced attributes such as xml and xlink
- Attribute values preserve exact strings including whitespace, URLs, and custom data attributes
파일
- PROMPT.md
- csx.json
- go.mod
- go.sum
- sample.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.Attribute in pkg:golang/golang.org/x/net@v0.47.0
Kind: HOW
Use EXACTLY these public packages and versions:
- pkg:golang/golang.org/x/net@v0.47.0
Demonstrate these symbols/APIs:
- golang.org/x/net/html.Attribute
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:c15870b00be5064b249bcf8d5b58a70c6f1923c3cd6feaf5a6f5f1bd4caee322","contract":["Attribute struct fields Namespace, Key, and Val represent HTML element attributes","html.Parse extracts element attributes into html.Node.Attr as a slice of html.Attribute","html.Render serializes html.Node with html.Attribute slice into valid HTML attribute syntax","Attribute supports namespaced attributes such as xml and xlink","Attribute values preserve exact strings including whitespace, URLs, and custom data attributes"],"goal":"verify golang.org/x/net/html.Attribute in pkg:golang/golang.org/x/net@v0.47.0","kind":"HOW","packages":["pkg:golang/golang.org/x/net@v0.47.0"],"schemaVersion":1,"symbols":["golang.org/x/net/html.Attribute"]},"contractCommand":["go","run","./test"],"environment":{"arch":"x64","distro":"ubuntu","ecosystem":"golang","language":"go","libc":"glibc","libcVersion":"2.39","os":"linux","osVersionBucket":"24","packageManager":"go","packageManagerVersion":"1.26.6","runtime":"go","runtimeVersion":"1.26.6","schemaVersion":1},"license":"MIT-0","packages":["pkg:golang/golang.org/x/net@v0.47.0"],"schemaVersion":1,"subject":"pkg:golang/golang.org/x/net@v0.47.0","symbols":["golang.org/x/net/html.Attribute"],"verifierAdapter":"golang@1"}
module sample
go 1.24.0
require golang.org/x/net v0.47.0
golang.org/x/net v0.47.0 h1:Mx+4dIFzqraBXUugkia1OOvlD6LemFo1ALMHjrXDOhY=
golang.org/x/net v0.47.0/go.mod h1:/jNxtkgq5yWUGYkaZGqo27cfGZ1c5Nen03aYrrKpVRU=
package sample
import (
"bytes"
"fmt"
"strings"
"golang.org/x/net/html"
)
// MakeAttribute creates an html.Attribute with optional namespace.
func MakeAttribute(namespace, key, val string) html.Attribute {
return html.Attribute{
Namespace: namespace,
Key: key,
Val: val,
}
}
// GetAttribute finds an attribute by key (ignoring namespace if empty).
func GetAttribute(attrs []html.Attribute, key string) (html.Attribute, bool) {
for _, a := range attrs {
if a.Key == key {
return a, true
}
}
return html.Attribute{}, false
}
// GetNamespacedAttribute finds an attribute matching both namespace and key.
func GetNamespacedAttribute(attrs []html.Attribute, namespace, key string) (html.Attribute, bool) {
for _, a := range attrs {
if a.Namespace == namespace && a.Key == key {
return a, true
}
}
return html.Attribute{}, false
}
// ParseAttributes parses an HTML snippet containing an element and returns its attributes.
func ParseAttributes(snippet string) ([]html.Attribute, error) {
node, err := html.Parse(strings.NewReader(snippet))
if err != nil {
return nil, fmt.Errorf("parse error: %w", err)
}
var found []html.Attribute
var search func(*html.Node)
search = func(n *html.Node) {
if n.Type == html.ElementNode && n.Data != "html" && n.Data != "head" && n.Data != "body" {
found = n.Attr
return
}
for c := n.FirstChild; c != nil; c = c.NextSibling {
search(c)
if found != nil {
return
}
}
}
search(node)
if found == nil {
return nil, fmt.Errorf("no target element node found")
}
return found, nil
}
// RenderAttributes creates an element node with the given tag and attributes, then renders it to HTML.
func RenderAttributes(tag string, attrs []html.Attribute) (string, error) {
node := &html.Node{
Type: html.ElementNode,
Data: tag,
Attr: attrs,
}
var buf bytes.Buffer
if err := html.Render(&buf, node); err != nil {
return "", fmt.Errorf("render error: %w", err)
}
return buf.String(), nil
}
{
"schemaVersion": 1,
"goal": "verify golang.org/x/net/html.Attribute in pkg:golang/golang.org/x/net@v0.47.0",
"kind": "HOW",
"packages": [
"pkg:golang/golang.org/x/net@v0.47.0"
],
"symbols": [
"golang.org/x/net/html.Attribute"
]
}
package main
import (
"fmt"
"os"
"strings"
"golang.org/x/net/html"
"sample"
)
func main() {
// Assertion 1: Attribute struct fields Namespace, Key, and Val represent HTML element attributes
attr1 := sample.MakeAttribute("", "id", "test-id")
if attr1.Namespace != "" || attr1.Key != "id" || attr1.Val != "test-id" {
fmt.Fprintf(os.Stderr, "FAIL: Assertion 1 failed: %v\n", attr1)
os.Exit(1)
}
// Assertion 2: html.Parse extracts element attributes into html.Node.Attr as a slice of html.Attribute
snippet := `<input type="text" name="query" value="search term" required>`
parsedAttrs, err := sample.ParseAttributes(snippet)
if err != nil {
fmt.Fprintf(os.Stderr, "FAIL: Assertion 2 failed to parse: %v\n", err)
os.Exit(1)
}
if len(parsedAttrs) != 4 {
fmt.Fprintf(os.Stderr, "FAIL: Assertion 2 failed: expected 4 attributes, got %d\n", len(parsedAttrs))
os.Exit(1)
}
typeAttr, ok := sample.GetAttribute(parsedAttrs, "type")
if !ok || typeAttr.Val != "text" {
fmt.Fprintf(os.Stderr, "FAIL: Assertion 2 failed: type attr mismatch: %v\n", typeAttr)
os.Exit(1)
}
nameAttr, ok := sample.GetAttribute(parsedAttrs, "name")
if !ok || nameAttr.Val != "query" {
fmt.Fprintf(os.Stderr, "FAIL: Assertion 2 failed: name attr mismatch: %v\n", nameAttr)
os.Exit(1)
}
// Assertion 3: html.Render serializes html.Node with html.Attribute slice into valid HTML attribute syntax
renderAttrs := []html.Attribute{
{Key: "href", Val: "https://example.com/api?a=1&b=2"},
{Key: "title", Val: "Quotes & Ampersands"},
}
rendered, err := sample.RenderAttributes("a", renderAttrs)
if err != nil {
fmt.Fprintf(os.Stderr, "FAIL: Assertion 3 failed to render: %v\n", err)
os.Exit(1)
}
if !strings.Contains(rendered, `href="https://example.com/api?a=1&b=2"`) || !strings.Contains(rendered, `title="Quotes & Ampersands"`) {
fmt.Fprintf(os.Stderr, "FAIL: Assertion 3 failed: rendered mismatch: %s\n", rendered)
os.Exit(1)
}
// Assertion 4: Attribute supports namespaced attributes such as xml and xlink
nsAttrs := []html.Attribute{
sample.MakeAttribute("xml", "lang", "en"),
sample.MakeAttribute("xlink", "href", "#icon-check"),
}
xmlAttr, ok := sample.GetNamespacedAttribute(nsAttrs, "xml", "lang")
if !ok || xmlAttr.Val != "en" {
fmt.Fprintf(os.Stderr, "FAIL: Assertion 4 failed: xml:lang mismatch: %v\n", xmlAttr)
os.Exit(1)
}
xlinkAttr, ok := sample.GetNamespacedAttribute(nsAttrs, "xlink", "href")
if !ok || xlinkAttr.Val != "#icon-check" {
fmt.Fprintf(os.Stderr, "FAIL: Assertion 4 failed: xlink:href mismatch: %v\n", xlinkAttr)
os.Exit(1)
}
// Assertion 5: Attribute values preserve exact strings including whitespace, URLs, and custom data attributes
customSnippet := `<div data-user="alice smith" data-url="https://example.com/profile" data-json='{"active":true}'></div>`
dataAttrs, err := sample.ParseAttributes(customSnippet)
if err != nil {
fmt.Fprintf(os.Stderr, "FAIL: Assertion 5 failed to parse custom attributes: %v\n", err)
os.Exit(1)
}
userAttr, ok := sample.GetAttribute(dataAttrs, "data-user")
if !ok || userAttr.Val != "alice smith" {
fmt.Fprintf(os.Stderr, "FAIL: Assertion 5 failed: data-user mismatch: %v\n", userAttr)
os.Exit(1)
}
urlAttr, ok := sample.GetAttribute(dataAttrs, "data-url")
if !ok || urlAttr.Val != "https://example.com/profile" {
fmt.Fprintf(os.Stderr, "FAIL: Assertion 5 failed: data-url mismatch: %v\n", urlAttr)
os.Exit(1)
}
jsonAttr, ok := sample.GetAttribute(dataAttrs, "data-json")
if !ok || jsonAttr.Val != `{"active":true}` {
fmt.Fprintf(os.Stderr, "FAIL: Assertion 5 failed: data-json mismatch: %v\n", jsonAttr)
os.Exit(1)
}
fmt.Println("PASS")
}
오리진 시더
익명