CodeSampleX

Sample

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

Verified sample for golang golang.org/x/net v0.0.0-20191119073136-fc4aabc6c914: html.StartTagToken. The contract ran on go 1.26 · linux debian/x64 · docker…

sha256:b8089b67aa4e11fad11f2303a2f664fc29bfb41a947240d9c7cc5589acbffbf0

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-28

Case

HOW
Goal
verify golang.org/x/net/html.StartTagToken in pkg:golang/golang.org/x/net@v0.0.0-20191119073136-fc4aabc6c914
Packages
Symbols
  • golang.org/x/net/html.StartTagToken
Created
2026-10-28T18:25:36Z

Contract

  1. html.StartTagToken is a TokenType constant with numeric value 2 and String() == "StartTag", distinct from other TokenType constants
  2. Tokenizer.Next returns html.StartTagToken for opening HTML elements and void elements without a trailing slash
  3. Tokenizer.Token on a StartTagToken populates Type as html.StartTagToken, Data, DataAtom, and parsed Attr slice
  4. Tokenizer.TagName and Tokenizer.TagAttr extract the tag name and sequential key/value attributes from a StartTagToken
  5. html.Token with Type html.StartTagToken formats as an opening HTML tag string via Token.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.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.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:614b67c16cc00de77c8f6c0e65bc809bae5af30c60c48525e110a28c7a5885e3","contract":["html.StartTagToken is a TokenType constant with numeric value 2 and String() == \"StartTag\", distinct from other TokenType constants","Tokenizer.Next returns html.StartTagToken for opening HTML elements and void elements without a trailing slash","Tokenizer.Token on a StartTagToken populates Type as html.StartTagToken, Data, DataAtom, and parsed Attr slice","Tokenizer.TagName and Tokenizer.TagAttr extract the tag name and sequential key/value attributes from a StartTagToken","html.Token with Type html.StartTagToken formats as an opening HTML tag string via Token.String()"],"goal":"verify golang.org/x/net/html.StartTagToken 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.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.0.0-20191119073136-fc4aabc6c914"],"schemaVersion":1,"subject":"pkg:golang/golang.org/x/net@v0.0.0-20191119073136-fc4aabc6c914","symbols":["golang.org/x/net/html.StartTagToken"],"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=
main.go
package main

import (
	"fmt"
	"io"
	"strings"

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

func main() {
	src := `<nav id="primary"><a href="https://example.com/docs" rel="noopener">Docs</a></nav>`
	tz := html.NewTokenizer(strings.NewReader(src))

	for {
		tt := tz.Next()
		if tt == html.ErrorToken {
			if tz.Err() == io.EOF {
				break
			}
			panic(tz.Err())
		}
		if tt == html.StartTagToken {
			tok := tz.Token()
			fmt.Printf("%s: <%s> (attrs=%d)\n", tt.String(), tok.Data, len(tok.Attr))
		}
	}
}
spec.json
{
  "schemaVersion": 1,
  "goal": "verify golang.org/x/net/html.StartTagToken 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.StartTagToken"
  ]
}
test/contract.go
package main

import (
	"fmt"
	"os"
	"strings"

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

func fail(format string, args ...any) {
	fmt.Fprintf(os.Stderr, "FAIL: "+format+"\n", args...)
	os.Exit(1)
}

func main() {
	// 1. StartTagToken is an html.TokenType constant with numeric value 2 and String() == "StartTag"
	var tt html.TokenType = html.StartTagToken
	if tt != 2 {
		fail("expected html.StartTagToken numeric value 2, got %d", tt)
	}
	if tt.String() != "StartTag" {
		fail("expected html.StartTagToken.String() == %q, got %q", "StartTag", tt.String())
	}

	// 2. StartTagToken is distinct from other html.TokenType constants
	others := []html.TokenType{
		html.ErrorToken,
		html.TextToken,
		html.EndTagToken,
		html.SelfClosingTagToken,
		html.CommentToken,
		html.DoctypeToken,
	}
	for _, other := range others {
		if html.StartTagToken == other {
			fail("expected StartTagToken to differ from %v", other)
		}
	}

	// 3. Tokenizer.Next() returns html.StartTagToken for opening HTML elements and void elements without trailing slash
	tz := html.NewTokenizer(strings.NewReader(`<section id="hero" data-role="banner"><input type="search" name="q"><span>text</span></section>`))
	if got := tz.Next(); got != html.StartTagToken {
		fail("expected StartTagToken for <section>, got %v", got)
	}

	// 4. Tokenizer.Token() on a StartTagToken populates Type, Data, DataAtom, and Attr
	tok := tz.Token()
	if tok.Type != html.StartTagToken {
		fail("expected Token.Type == StartTagToken, got %v", tok.Type)
	}
	if tok.Data != "section" || tok.DataAtom != atom.Section {
		fail("expected Data='section' and DataAtom=atom.Section, got Data=%q DataAtom=%v", tok.Data, tok.DataAtom)
	}
	if len(tok.Attr) != 2 || tok.Attr[0].Key != "id" || tok.Attr[0].Val != "hero" || tok.Attr[1].Key != "data-role" || tok.Attr[1].Val != "banner" {
		fail("unexpected Token.Attr on <section>: %+v", tok.Attr)
	}

	// 5. Token.String() with Type == html.StartTagToken renders an opening tag with escaped attributes
	if got := tok.String(); got != `<section id="hero" data-role="banner">` {
		fail("unexpected Token.String(): %q", got)
	}

	// 6. Void element without trailing slash yields html.StartTagToken and supports TagName() / TagAttr()
	if got := tz.Next(); got != html.StartTagToken {
		fail("expected StartTagToken for <input>, got %v", got)
	}
	name, hasAttr := tz.TagName()
	if string(name) != "input" || !hasAttr {
		fail("expected TagName 'input' with hasAttr=true, got %q (hasAttr=%v)", string(name), hasAttr)
	}
	k1, v1, more1 := tz.TagAttr()
	if string(k1) != "type" || string(v1) != "search" || !more1 {
		fail("unexpected first TagAttr: %q=%q (more=%v)", string(k1), string(v1), more1)
	}
	k2, v2, more2 := tz.TagAttr()
	if string(k2) != "name" || string(v2) != "q" || more2 {
		fail("unexpected second TagAttr: %q=%q (more=%v)", string(k2), string(v2), more2)
	}

	// 7. Subsequent opening tag <span> also yields html.StartTagToken with hasAttr=false
	if got := tz.Next(); got != html.StartTagToken {
		fail("expected StartTagToken for <span>, got %v", got)
	}
	spanName, spanHasAttr := tz.TagName()
	if string(spanName) != "span" || spanHasAttr {
		fail("expected TagName 'span' with hasAttr=false, got %q (hasAttr=%v)", string(spanName), spanHasAttr)
	}
}

Origin Seeder

anonymous