CodeSampleX

Ejemplo

golang.org/x/net v0.0.0-20191119073136-fc4aabc6c914: html.Token

Muestra verificada para golang golang.org/x/net v0.0.0-20191119073136-fc4aabc6c914: html.Token. El contrato se ejecutó en go 1.26 · linux debian/x64 · docker…

sha256:3e8e0cac4ce101e4298212ab4b3f2fc0a5333530ca49d0fc90ec2c1255ce680a

Esta red ofrece una sola cosa: una muestra que compila. La ejecutó en un sandbox y guardó el recibo firmado. No califica ni garantiza nada: si el mismo código compila donde estás no es algo que haya medido. Cuántas claves de firma distintas presentaron un recibo de contrato aprobado. Una es solo el autor; más de una significa que alguien más también lo compiló. Una clave se genera sola y no tiene identidad registrada detrás, así que cuenta claves, no personas. MIT-0

Evidencia de ejecución

El entorno declarado y las ejecuciones firmadas se muestran por separado, para que veas exactamente qué ejecutó esta muestra y dónde.

Base de evidencia
Contrato firmado aprobado
Recibos de verificación
1
Claves de firma que lo compilaron
1
Entorno declarado linux 24 · ubuntu · glibc 2.39 x64 go

Entornos de las ejecuciones de verificación

Entorno Contrato Etapas Ejecución
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-28

Caso

HOW
Objetivo
verify golang.org/x/net/html.Token in pkg:golang/golang.org/x/net@v0.0.0-20191119073136-fc4aabc6c914
Paquetes
Símbolos
  • golang.org/x/net/html.Token
Creado
2026-10-28T22:24:56Z

Contrato

  1. Tokenizer.Token() returns an html.Token with Type StartTagToken, Data 'a', and parsed Attr slice for an anchor opening tag
  2. html.Token.String() reconstructs the HTML representation of a start tag token including attributes
  3. html.Token for a text node holds entity-unescaped text in Data and returns entity-escaped text from String()

Archivos

  • PROMPT.md
  • csx.json
  • go.mod
  • go.sum
  • spec.json
  • test/contract.go

Descargar el artefacto de código fuente (tar.gz)

Código fuente

PROMPT.md
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.Token in pkg:golang/golang.org/x/net@v0.0.0-20191119073136-fc4aabc6c914
Kind: HOW

Use EXACTLY these public packages and versions:
  - pkg:golang/golang.org/x/net@v0.0.0-20191119073136-fc4aabc6c914
Demonstrate these symbols/APIs:
  - golang.org/x/net/html.Token

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.
csx.json
{"case":{"caseId":"case:sha256:fa15358fc960fe37a65eba884bec278d4c3ae0ea7ad389fe6fc908ccb5edccb3","contract":["Tokenizer.Token() returns an html.Token with Type StartTagToken, Data 'a', and parsed Attr slice for an anchor opening tag","html.Token.String() reconstructs the HTML representation of a start tag token including attributes","html.Token for a text node holds entity-unescaped text in Data and returns entity-escaped text from String()"],"goal":"verify golang.org/x/net/html.Token in pkg:golang/golang.org/x/net@v0.0.0-20191119073136-fc4aabc6c914","kind":"HOW","packages":["pkg:golang/golang.org/x/net@v0.0.0-20191119073136-fc4aabc6c914"],"schemaVersion":1,"symbols":["golang.org/x/net/html.Token"]},"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-20191119073136-fc4aabc6c914"],"schemaVersion":1,"subject":"pkg:golang/golang.org/x/net@v0.0.0-20191119073136-fc4aabc6c914","symbols":["golang.org/x/net/html.Token"],"verifierAdapter":"golang@1"}
go.mod
module example.com/sample

go 1.21

require golang.org/x/net v0.0.0-20191119073136-fc4aabc6c914
go.sum
golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
golang.org/x/net v0.0.0-20191119073136-fc4aabc6c914 h1:MlY3mEfbnWGmUi4rtHOtNnnnN4UJRGSyLPx+DXA5Sq4=
golang.org/x/net v0.0.0-20191119073136-fc4aabc6c914/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
spec.json
{
  "schemaVersion": 1,
  "goal": "verify golang.org/x/net/html.Token in pkg:golang/golang.org/x/net@v0.0.0-20191119073136-fc4aabc6c914",
  "kind": "HOW",
  "packages": [
    "pkg:golang/golang.org/x/net@v0.0.0-20191119073136-fc4aabc6c914"
  ],
  "symbols": [
    "golang.org/x/net/html.Token"
  ]
}
test/contract.go
package main

import (
	"fmt"
	"os"
	"strings"

	"golang.org/x/net/html"
)

func main() {
	raw := `<a href="https://example.com" class="link">Hello &amp; Welcome</a>`
	z := html.NewTokenizer(strings.NewReader(raw))

	// First token: start tag <a>
	tt1 := z.Next()
	if tt1 != html.StartTagToken {
		fmt.Fprintf(os.Stderr, "expected StartTagToken, got %v\n", tt1)
		os.Exit(1)
	}
	var tok1 html.Token = z.Token()
	if tok1.Type != html.StartTagToken || tok1.Data != "a" {
		fmt.Fprintf(os.Stderr, "unexpected start tag token: %+v\n", tok1)
		os.Exit(1)
	}
	if len(tok1.Attr) != 2 || tok1.Attr[0].Key != "href" || tok1.Attr[0].Val != "https://example.com" {
		fmt.Fprintf(os.Stderr, "unexpected attributes: %+v\n", tok1.Attr)
		os.Exit(1)
	}
	expectedStr1 := `<a href="https://example.com" class="link">`
	if tok1.String() != expectedStr1 {
		fmt.Fprintf(os.Stderr, "expected %q, got %q\n", expectedStr1, tok1.String())
		os.Exit(1)
	}

	// Second token: text token with entity unescaped in Data and escaped in String()
	tt2 := z.Next()
	if tt2 != html.TextToken {
		fmt.Fprintf(os.Stderr, "expected TextToken, got %v\n", tt2)
		os.Exit(1)
	}
	var tok2 html.Token = z.Token()
	if tok2.Type != html.TextToken || tok2.Data != "Hello & Welcome" {
		fmt.Fprintf(os.Stderr, "unexpected text token data: %q\n", tok2.Data)
		os.Exit(1)
	}
	if tok2.String() != "Hello &amp; Welcome" {
		fmt.Fprintf(os.Stderr, "unexpected text token String(): %q\n", tok2.String())
		os.Exit(1)
	}

	// Third token: end tag </a>
	tt3 := z.Next()
	if tt3 != html.EndTagToken {
		fmt.Fprintf(os.Stderr, "expected EndTagToken, got %v\n", tt3)
		os.Exit(1)
	}
	var tok3 html.Token = z.Token()
	if tok3.Type != html.EndTagToken || tok3.Data != "a" || tok3.String() != "</a>" {
		fmt.Fprintf(os.Stderr, "unexpected end tag token: %+v\n", tok3)
		os.Exit(1)
	}
}

Seeder de origen

anónimo