Beispiel
golang.org/x/net v0.61.0: html.EndTagToken
Verifiziertes Beispiel für golang golang.org/x/net v0.61.0: html.EndTagToken. Der Vertrag lief auf go 1.26 · linux debian/x64 · docker und bestand.
sha256:4a1b2db965042a29d4637814833266aa23dc2646bd52c967d5fb5d04e49d065a
Dieses Netzwerk bietet eine Sache: ein Sample, das baut. Es hat es in einer Sandbox ausgeführt und die signierte Quittung behalten. Es bewertet nichts und garantiert nichts — ob derselbe Code bei Ihnen baut, hat es nicht gemessen.
Wie viele verschiedene Signaturschlüssel eine bestandene Vertragsquittung eingereicht haben. Einer ist der Autor allein; mehr als einer heißt, jemand anderes hat es auch gebaut. Ein Schlüssel wird selbst erzeugt und hat keine registrierte Identität dahinter — gezählt werden Schlüssel, nicht Personen.
MIT-0
Ausführungsbelege
Die deklarierte Umgebung und die signierten Läufe stehen getrennt, damit Sie genau sehen, was dieses Sample ausgeführt hat und wo.
- Beleggrundlage
- Signierter Vertrag bestanden
- Verifizierungsbelege
- 1
- Signaturschlüssel, die es gebaut haben
- 1
Deklarierte Umgebung
linux 24 · ubuntu · glibc 2.39 x64 go
Umgebungen der Verifizierungsläufe
| Umgebung | Contract | Stufen | Lauf |
|---|---|---|---|
| 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 |
Fall
HOW- Ziel
- verify golang.org/x/net/html.EndTagToken in pkg:golang/golang.org/x/net@v0.61.0
- Pakete
- Symbole
-
- golang.org/x/net/html.EndTagToken
- Erstellt
- 2026-10-12T06:29:18Z
Contract
- html.EndTagToken is a TokenType constant whose String() returns "EndTag"
- html.EndTagToken is distinct from StartTagToken, SelfClosingTagToken, TextToken, and CommentToken
- html.NewTokenizer emits html.EndTagToken when encountering closing tags
- html.Token with html.EndTagToken serializes to </tag> string representation
- Tokenizer.TagName returns tag name and no attributes for html.EndTagToken
Dateien
- PROMPT.md
- csx.json
- go.mod
- go.sum
- sample.go
- spec.json
- test/contract.go
Quelltext
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.EndTagToken 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.EndTagToken
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:4759ed07aa717651095533bf85fd4de008241bcef98f0f4628a265882b014942","contract":["html.EndTagToken is a TokenType constant whose String() returns \"EndTag\"","html.EndTagToken is distinct from StartTagToken, SelfClosingTagToken, TextToken, and CommentToken","html.NewTokenizer emits html.EndTagToken when encountering closing tags","html.Token with html.EndTagToken serializes to \u003c/tag\u003e string representation","Tokenizer.TagName returns tag name and no attributes for html.EndTagToken"],"goal":"verify golang.org/x/net/html.EndTagToken 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.EndTagToken"]},"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.EndTagToken"],"verifierAdapter":"golang@1"}
module sample
go 1.26.0
require golang.org/x/net v0.61.0
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=
package sample
import (
"errors"
"io"
"strings"
"golang.org/x/net/html"
)
// IsEndTag returns true if the token type represents an HTML end/closing tag.
func IsEndTag(tokenType html.TokenType) bool {
return tokenType == html.EndTagToken
}
// FormatEndTag creates an html.Token of type EndTagToken for the given tag name and returns its string.
func FormatEndTag(tagName string) string {
tok := html.Token{
Type: html.EndTagToken,
Data: tagName,
}
return tok.String()
}
// CollectClosingTags parses an HTML fragment and returns the names of all closing tags encountered.
func CollectClosingTags(htmlInput string) ([]string, error) {
tokenizer := html.NewTokenizer(strings.NewReader(htmlInput))
var closingTags []string
for {
tt := tokenizer.Next()
switch tt {
case html.ErrorToken:
err := tokenizer.Err()
if errors.Is(err, io.EOF) {
return closingTags, nil
}
return nil, err
case html.EndTagToken:
name, _ := tokenizer.TagName()
closingTags = append(closingTags, string(name))
}
}
}
// CheckBalancedTags checks whether every opened tag is matched by a corresponding EndTagToken.
func CheckBalancedTags(htmlInput string) (bool, error) {
tokenizer := html.NewTokenizer(strings.NewReader(htmlInput))
var tagStack []string
for {
tt := tokenizer.Next()
switch tt {
case html.ErrorToken:
err := tokenizer.Err()
if errors.Is(err, io.EOF) {
return len(tagStack) == 0, nil
}
return false, err
case html.StartTagToken:
name, _ := tokenizer.TagName()
tagStack = append(tagStack, string(name))
case html.EndTagToken:
name, _ := tokenizer.TagName()
tagName := string(name)
if len(tagStack) == 0 || tagStack[len(tagStack)-1] != tagName {
return false, nil
}
tagStack = tagStack[:len(tagStack)-1]
}
}
}
{
"schemaVersion": 1,
"goal": "verify golang.org/x/net/html.EndTagToken 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.EndTagToken"
]
}
package main
import (
"fmt"
"os"
"reflect"
"strings"
"golang.org/x/net/html"
"sample"
)
func main() {
// Assertion 1: html.EndTagToken is a TokenType constant whose String() returns "EndTag"
if html.EndTagToken.String() != "EndTag" {
fmt.Fprintf(os.Stderr, "Assertion 1 failed: expected 'EndTag', got %q\n", html.EndTagToken.String())
os.Exit(1)
}
if !sample.IsEndTag(html.EndTagToken) {
fmt.Fprintf(os.Stderr, "Assertion 1 failed: sample.IsEndTag(html.EndTagToken) was false\n")
os.Exit(1)
}
// Assertion 2: html.EndTagToken is distinct from StartTagToken, SelfClosingTagToken, TextToken, and CommentToken
if html.EndTagToken == html.StartTagToken ||
html.EndTagToken == html.SelfClosingTagToken ||
html.EndTagToken == html.TextToken ||
html.EndTagToken == html.CommentToken {
fmt.Fprintf(os.Stderr, "Assertion 2 failed: EndTagToken collides with another TokenType\n")
os.Exit(1)
}
if sample.IsEndTag(html.StartTagToken) || sample.IsEndTag(html.TextToken) {
fmt.Fprintf(os.Stderr, "Assertion 2 failed: sample.IsEndTag returned true for non-end tag\n")
os.Exit(1)
}
// Assertion 3: html.NewTokenizer emits html.EndTagToken when encountering closing tags
input := "<div><article><p>Text</p></article></div>"
tags, err := sample.CollectClosingTags(input)
if err != nil {
fmt.Fprintf(os.Stderr, "Assertion 3 failed with error: %v\n", err)
os.Exit(1)
}
expectedTags := []string{"p", "article", "div"}
if !reflect.DeepEqual(tags, expectedTags) {
fmt.Fprintf(os.Stderr, "Assertion 3 failed: expected %v, got %v\n", expectedTags, tags)
os.Exit(1)
}
// Assertion 4: html.Token with html.EndTagToken serializes to </tag> string representation
formatted := sample.FormatEndTag("footer")
if formatted != "</footer>" {
fmt.Fprintf(os.Stderr, "Assertion 4 failed: expected '</footer>', got %q\n", formatted)
os.Exit(1)
}
tok := html.Token{Type: html.EndTagToken, Data: "nav"}
if tok.String() != "</nav>" {
fmt.Fprintf(os.Stderr, "Assertion 4 failed: expected '</nav>', got %q\n", tok.String())
os.Exit(1)
}
// Assertion 5: Tokenizer.TagName returns tag name and no attributes for html.EndTagToken
z := html.NewTokenizer(strings.NewReader("</section>"))
tt := z.Next()
if tt != html.EndTagToken {
fmt.Fprintf(os.Stderr, "Assertion 5 failed: expected EndTagToken, got %v\n", tt)
os.Exit(1)
}
name, hasAttr := z.TagName()
if string(name) != "section" {
fmt.Fprintf(os.Stderr, "Assertion 5 failed: expected tag name 'section', got %q\n", string(name))
os.Exit(1)
}
if hasAttr {
fmt.Fprintf(os.Stderr, "Assertion 5 failed: expected hasAttr false for EndTagToken\n")
os.Exit(1)
}
// Helper verification: check balanced tags
balanced, err := sample.CheckBalancedTags("<ul><li>item</li></ul>")
if err != nil || !balanced {
fmt.Fprintf(os.Stderr, "CheckBalancedTags failed for balanced HTML: balanced=%v, err=%v\n", balanced, err)
os.Exit(1)
}
unbalanced, err := sample.CheckBalancedTags("<ul><li>item</ul></li>")
if err != nil || unbalanced {
fmt.Fprintf(os.Stderr, "CheckBalancedTags failed for unbalanced HTML: balanced=%v, err=%v\n", unbalanced, err)
os.Exit(1)
}
fmt.Println("PASS: all contract assertions passed")
}
Ursprungs-Seeder
anonym