CodeSampleX

Exemplo

golang.org/x/net v0.51.0: atom.Form

Amostra verificada para golang golang.org/x/net v0.51.0: atom.Form. O contrato rodou em go 1.26 · linux debian/x64 · docker e passou.

sha256:148d20fb7309f7687d579d04f671b1d1b58d909ed7c23eda4934d4bf53d35356

Esta rede oferece uma coisa: uma amostra que compila. Ela a executou em um sandbox e guardou o recibo assinado. Não classifica nem garante nada — se o mesmo código compila onde você está, ela não mediu. Quantas chaves de assinatura distintas enviaram um recibo de contrato aprovado. Uma é só o autor; mais de uma significa que outra pessoa também o compilou. Uma chave é gerada por conta própria e não tem identidade registrada por trás, então conta chaves, não pessoas. MIT-0

Evidência de execução

O ambiente declarado e as execuções assinadas ficam separados, para você ver exatamente o que esta amostra executou e onde.

Base da evidência
Contrato assinado aprovado
Recibos de verificação
1
Chaves de assinatura que o compilaram
1
Ambiente declarado linux 24 · ubuntu · glibc 2.39 x64 go

Ambientes das execuções de verificação

Ambiente Contrato Etapas Execução
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-09-07

Caso

HOW
Objetivo
verify golang.org/x/net/html/atom.Form in pkg:golang/golang.org/x/net@v0.51.0
Pacotes
Símbolos
  • golang.org/x/net/html/atom.Form
Criado
2026-09-07T00:06:11Z

Contrato

  1. atom.Form is a non-zero Atom constant representing the form HTML tag
  2. atom.Form String method returns lowercase string "form"
  3. atom.Lookup with byte slice "form" returns atom.Form
  4. atom.Lookup is case-sensitive and returns 0 for byte slice "FORM"
  5. atom.String with byte slice "form" returns "form"
  6. atom.Form is distinct from atom.Input, atom.Div, and atom.Formaction
  7. html.Tokenizer yields a start tag token with DataAtom equal to atom.Form when tokenizing a form tag
  8. html.Parse generates an ElementNode with DataAtom equal to atom.Form for a form element

Arquivos

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

Baixar o artefato de código-fonte (tar.gz)

Código-fonte

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

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

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:b8278b2caed46c81a90886be97faa5abfacd110c2dea4f577023bef377c01cc6","contract":["atom.Form is a non-zero Atom constant representing the form HTML tag","atom.Form String method returns lowercase string \"form\"","atom.Lookup with byte slice \"form\" returns atom.Form","atom.Lookup is case-sensitive and returns 0 for byte slice \"FORM\"","atom.String with byte slice \"form\" returns \"form\"","atom.Form is distinct from atom.Input, atom.Div, and atom.Formaction","html.Tokenizer yields a start tag token with DataAtom equal to atom.Form when tokenizing a form tag","html.Parse generates an ElementNode with DataAtom equal to atom.Form for a form element"],"goal":"verify golang.org/x/net/html/atom.Form in pkg:golang/golang.org/x/net@v0.51.0","kind":"HOW","packages":["pkg:golang/golang.org/x/net@v0.51.0"],"schemaVersion":1,"symbols":["golang.org/x/net/html/atom.Form"]},"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.51.0"],"schemaVersion":1,"subject":"pkg:golang/golang.org/x/net@v0.51.0","symbols":["golang.org/x/net/html/atom.Form"],"verifierAdapter":"golang@1"}
go.mod
module example.com/sample

go 1.26.6

require golang.org/x/net v0.51.0
go.sum
golang.org/x/net v0.51.0 h1:94R/GTO7mt3/4wIKpcR5gkGmRLOuE/2hNGeWq/GBIFo=
golang.org/x/net v0.51.0/go.mod h1:aamm+2QF5ogm02fjy5Bb7CQ0WMt1/WVM7FtyaTLlA9Y=
main.go
package main

import (
	"fmt"
	"io"
	"strings"

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

func main() {
	// Demonstrating atom.Form properties
	fmt.Printf("atom.Form: value=%d, string=%q\n", atom.Form, atom.Form.String())

	// Lookup atom from bytes
	lookupForm := atom.Lookup([]byte("form"))
	fmt.Printf("atom.Lookup(\"form\") == atom.Form: %t\n", lookupForm == atom.Form)

	// Tokenize HTML containing a form
	htmlSnippet := `<form action="/submit" method="post"><input type="text" name="q"/></form>`
	z := html.NewTokenizer(strings.NewReader(htmlSnippet))

	for {
		tt := z.Next()
		if tt == html.ErrorToken {
			if z.Err() == io.EOF {
				break
			}
			fmt.Printf("Token error: %v\n", z.Err())
			break
		}

		tok := z.Token()
		if tok.DataAtom == atom.Form {
			fmt.Printf("Matched token DataAtom == atom.Form: type=%s, tag=%s\n", tt.String(), tok.Data)
		}
	}
}
spec.json
{
  "schemaVersion": 1,
  "goal": "verify golang.org/x/net/html/atom.Form in pkg:golang/golang.org/x/net@v0.51.0",
  "kind": "HOW",
  "packages": [
    "pkg:golang/golang.org/x/net@v0.51.0"
  ],
  "symbols": [
    "golang.org/x/net/html/atom.Form"
  ]
}
test/contract.go
package main

import (
	"fmt"
	"os"
	"strings"

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

func main() {
	if err := runTests(); err != nil {
		fmt.Fprintf(os.Stderr, "Contract test failed: %v\n", err)
		os.Exit(1)
	}
	fmt.Println("All contract assertions passed.")
}

func runTests() error {
	// 1. atom.Form is a non-zero Atom constant representing the form HTML tag
	if atom.Form == 0 {
		return fmt.Errorf("expected atom.Form != 0, got 0")
	}

	// 2. atom.Form String method returns lowercase string "form"
	if s := atom.Form.String(); s != "form" {
		return fmt.Errorf("expected atom.Form.String() == \"form\", got %q", s)
	}

	// 3. atom.Lookup with byte slice "form" returns atom.Form
	if a := atom.Lookup([]byte("form")); a != atom.Form {
		return fmt.Errorf("expected atom.Lookup([]byte(\"form\")) == atom.Form, got %v", a)
	}

	// 4. atom.Lookup is case-sensitive and returns 0 for byte slice "FORM"
	if a := atom.Lookup([]byte("FORM")); a != 0 {
		return fmt.Errorf("expected atom.Lookup([]byte(\"FORM\")) == 0, got %v", a)
	}

	// 5. atom.String with byte slice "form" returns "form"
	if s := atom.String([]byte("form")); s != "form" {
		return fmt.Errorf("expected atom.String([]byte(\"form\")) == \"form\", got %q", s)
	}

	// 6. atom.Form is distinct from atom.Input, atom.Div, and atom.Formaction
	if atom.Form == atom.Input || atom.Form == atom.Div || atom.Form == atom.Formaction {
		return fmt.Errorf("atom.Form collides with another atom")
	}

	// 7. html.Tokenizer yields a start tag token with DataAtom equal to atom.Form when tokenizing a form tag
	z := html.NewTokenizer(strings.NewReader(`<form action="/submit" method="post"><input type="text"/></form>`))
	tt := z.Next()
	if tt != html.StartTagToken {
		return fmt.Errorf("expected html.StartTagToken, got %v", tt)
	}
	tok := z.Token()
	if tok.DataAtom != atom.Form {
		return fmt.Errorf("expected tok.DataAtom == atom.Form, got %v", tok.DataAtom)
	}
	if tok.Data != "form" {
		return fmt.Errorf("expected tok.Data == \"form\", got %q", tok.Data)
	}

	// 8. html.Parse generates an ElementNode with DataAtom equal to atom.Form for a form element
	doc, err := html.Parse(strings.NewReader(`<html><body><form id="test-form"></form></body></html>`))
	if err != nil {
		return fmt.Errorf("html.Parse failed: %w", err)
	}
	var foundForm *html.Node
	var findForm func(*html.Node)
	findForm = func(n *html.Node) {
		if n.Type == html.ElementNode && n.DataAtom == atom.Form {
			foundForm = n
			return
		}
		for c := n.FirstChild; c != nil; c = c.NextSibling {
			findForm(c)
		}
	}
	findForm(doc)
	if foundForm == nil {
		return fmt.Errorf("expected to find form node with DataAtom == atom.Form in parsed HTML")
	}
	if foundForm.Data != "form" {
		return fmt.Errorf("expected foundForm.Data == \"form\", got %q", foundForm.Data)
	}

	return nil
}

Seeder de origem

anônimo