CodeSampleX

Sample

golang.org/x/net v0.61.0: html.StartTagToken

Verified sample for golang golang.org/x/net v0.61.0: html.StartTagToken. The contract ran on go 1.26 · linux debian/x64 · docker and passed.

sha256:bc7077b92132f661408e87ea4e4be4a1b8e59173a72c79404ea744cf38d6b16e

This network offers one thing: a sample that builds. It ran the sample in a sandbox and kept the signed receipt. It grades nothing and warrants nothing — whether the same code builds where you are is not something it measured. How many distinct signing keys filed a passing contract receipt. One is the author alone; more than one means somebody else built it too. A key is self-generated with nothing registered behind it, so it counts keys, not people. MIT-0

Execution evidence

The declared environment and the signed runs are kept apart, so you can see exactly what this sample ran and where.

Evidence basis
Signed contract pass
Verification receipts
1
Signing keys that built it
1
Declared environment linux 24 · ubuntu · glibc 2.39 x64 go

Verification-run environments

Environment Contract Stages Run
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-12

Case

HOW
Goal
verify golang.org/x/net/html.StartTagToken in pkg:golang/golang.org/x/net@v0.61.0
Packages
Symbols
  • golang.org/x/net/html.StartTagToken
Created
2026-10-12T08:12:11Z

Contract

  1. StartTagToken is a TokenType constant with value 2 representing start tags
  2. StartTagToken String method returns string representation "StartTag"
  3. StartTagToken is distinct from EndTagToken, SelfClosingTagToken, and ErrorToken
  4. Tokenizer Next returns StartTagToken for opening elements
  5. Tokenizer Next returns StartTagToken for void elements without trailing slash
  6. Tokenizer Token returns a Token with Type StartTagToken, tag Data, DataAtom, and parsed Attributes
  7. Tokenizer TagName and TagAttr extract name and sequential attributes from StartTagToken
  8. Token with Type StartTagToken renders opening tag format via String

Files

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

Download the source artifact (tar.gz)

Source

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.StartTagToken in pkg:golang/golang.org/x/net@v0.61.0
Kind: HOW

Use EXACTLY these public packages and versions:
  - pkg:golang/golang.org/x/net@v0.61.0
Demonstrate these symbols/APIs:
  - golang.org/x/net/html.StartTagToken

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:d92be6b1b0c39ecdb4d997e804a4e234e54c8e2ed05effa7b8aeff947070f2f9","contract":["StartTagToken is a TokenType constant with value 2 representing start tags","StartTagToken String method returns string representation \"StartTag\"","StartTagToken is distinct from EndTagToken, SelfClosingTagToken, and ErrorToken","Tokenizer Next returns StartTagToken for opening elements","Tokenizer Next returns StartTagToken for void elements without trailing slash","Tokenizer Token returns a Token with Type StartTagToken, tag Data, DataAtom, and parsed Attributes","Tokenizer TagName and TagAttr extract name and sequential attributes from StartTagToken","Token with Type StartTagToken renders opening tag format via String"],"goal":"verify golang.org/x/net/html.StartTagToken in pkg:golang/golang.org/x/net@v0.61.0","kind":"HOW","packages":["pkg:golang/golang.org/x/net@v0.61.0"],"schemaVersion":1,"symbols":["golang.org/x/net/html.StartTagToken"]},"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.61.0"],"schemaVersion":1,"subject":"pkg:golang/golang.org/x/net@v0.61.0","symbols":["golang.org/x/net/html.StartTagToken"],"verifierAdapter":"golang@1"}
go.mod
module example.com/sample

go 1.26.6

require golang.org/x/net v0.61.0
go.sum
golang.org/x/net v0.61.0 h1:RR+6j/BTBCrggOLugxa+66R8FvoN6MHlzDlZIbN9YFw=
golang.org/x/net v0.61.0/go.mod h1:WgDCOTH8iwtB66T4/GfI94AHo/hhdb7Hah9NDseQfiI=
main.go
package main

import (
	"fmt"
	"io"
	"strings"

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

func main() {
	htmlContent := `<div class="container" id="main"><p>Sample content</p><a href="https://example.com" target="_blank">Link</a></div>`
	z := html.NewTokenizer(strings.NewReader(htmlContent))

	fmt.Println("Tokenizing HTML with StartTagToken:")
	for {
		tt := z.Next()
		if tt == html.ErrorToken {
			if z.Err() == io.EOF {
				break
			}
			fmt.Printf("Tokenization error: %v\n", z.Err())
			break
		}

		if tt == html.StartTagToken {
			tok := z.Token()
			fmt.Printf("Found StartTagToken [%s]: %s (tag: %s, attrs: %d)\n",
				tt.String(), tok.String(), tok.Data, len(tok.Attr))
			for _, attr := range tok.Attr {
				fmt.Printf("  attr: %s=%q\n", attr.Key, attr.Val)
			}
		}
	}
}
spec.json
{
  "schemaVersion": 1,
  "goal": "verify golang.org/x/net/html.StartTagToken in pkg:golang/golang.org/x/net@v0.61.0",
  "kind": "HOW",
  "packages": [
    "pkg:golang/golang.org/x/net@v0.61.0"
  ],
  "symbols": [
    "golang.org/x/net/html.StartTagToken"
  ]
}
test/contract.go
package main

import (
	"fmt"
	"os"
	"strings"

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

func main() {
	// 1. StartTagToken is a TokenType constant with value 2 representing start tags
	if html.StartTagToken != 2 {
		fmt.Fprintf(os.Stderr, "Expected StartTagToken to have value 2, got %d\n", html.StartTagToken)
		os.Exit(1)
	}

	// 2. StartTagToken String method returns string representation "StartTag"
	if html.StartTagToken.String() != "StartTag" {
		fmt.Fprintf(os.Stderr, "Expected StartTagToken.String() to be %q, got %q\n", "StartTag", html.StartTagToken.String())
		os.Exit(1)
	}

	// 3. StartTagToken is distinct from EndTagToken, SelfClosingTagToken, and ErrorToken
	if html.StartTagToken == html.EndTagToken || html.StartTagToken == html.SelfClosingTagToken || html.StartTagToken == html.ErrorToken {
		fmt.Fprintf(os.Stderr, "Expected StartTagToken to be distinct from EndTagToken, SelfClosingTagToken, and ErrorToken\n")
		os.Exit(1)
	}

	// 4. Tokenizer Next returns StartTagToken for opening elements
	zElem := html.NewTokenizer(strings.NewReader(`<div class="box" id="content">`))
	ttElem := zElem.Next()
	if ttElem != html.StartTagToken {
		fmt.Fprintf(os.Stderr, "Expected StartTagToken for <div>, got %v\n", ttElem)
		os.Exit(1)
	}

	// 5. Tokenizer Next returns StartTagToken for void elements without trailing slash
	zVoid := html.NewTokenizer(strings.NewReader(`<input type="text" name="q">`))
	ttVoid := zVoid.Next()
	if ttVoid != html.StartTagToken {
		fmt.Fprintf(os.Stderr, "Expected StartTagToken for <input> without slash, got %v\n", ttVoid)
		os.Exit(1)
	}

	// 6. Tokenizer Token returns a Token with Type StartTagToken, tag Data, DataAtom, and parsed Attributes
	tok := zElem.Token()
	if tok.Type != html.StartTagToken {
		fmt.Fprintf(os.Stderr, "Expected tok.Type to be StartTagToken, got %v\n", tok.Type)
		os.Exit(1)
	}
	if tok.Data != "div" || tok.DataAtom != atom.Div {
		fmt.Fprintf(os.Stderr, "Expected Data='div' and DataAtom=atom.Div, got Data=%q DataAtom=%v\n", tok.Data, tok.DataAtom)
		os.Exit(1)
	}
	if len(tok.Attr) != 2 || tok.Attr[0].Key != "class" || tok.Attr[0].Val != "box" || tok.Attr[1].Key != "id" || tok.Attr[1].Val != "content" {
		fmt.Fprintf(os.Stderr, "Unexpected attributes: %+v\n", tok.Attr)
		os.Exit(1)
	}

	// 7. Tokenizer TagName and TagAttr extract name and sequential attributes from StartTagToken
	zStream := html.NewTokenizer(strings.NewReader(`<a href="https://example.com" target="_blank">`))
	if tt := zStream.Next(); tt != html.StartTagToken {
		fmt.Fprintf(os.Stderr, "Expected StartTagToken for <a> tag, got %v\n", tt)
		os.Exit(1)
	}
	name, hasAttr := zStream.TagName()
	if string(name) != "a" || !hasAttr {
		fmt.Fprintf(os.Stderr, "Expected TagName 'a' with hasAttr=true, got %q, %v\n", string(name), hasAttr)
		os.Exit(1)
	}
	k1, v1, more1 := zStream.TagAttr()
	if string(k1) != "href" || string(v1) != "https://example.com" || !more1 {
		fmt.Fprintf(os.Stderr, "Expected first attr href=https://example.com more=true, got %s=%s more=%v\n", k1, v1, more1)
		os.Exit(1)
	}
	k2, v2, more2 := zStream.TagAttr()
	if string(k2) != "target" || string(v2) != "_blank" || more2 {
		fmt.Fprintf(os.Stderr, "Expected second attr target=_blank more=false, got %s=%s more=%v\n", k2, v2, more2)
		os.Exit(1)
	}

	// 8. Token with Type StartTagToken renders opening tag format via String
	rendered := tok.String()
	if rendered != `<div class="box" id="content">` {
		fmt.Fprintf(os.Stderr, "Expected rendered tag %q, got %q\n", `<div class="box" id="content">`, rendered)
		os.Exit(1)
	}

	fmt.Println("All contract assertions passed.")
}

Origin Seeder

anonymous