CodeSampleX

Пример

golang.org/x/net v0.0.0-20210525063256-abc453219eb5: atom.Form

Проверенный пример — golang golang.org/x/net v0.0.0-20210525063256-abc453219eb5: atom.Form. Контракт выполнен на go 1.26 · linux debian/x64 · docker и…

sha256:ff8e5b9f11a20a02c20eea46762bd6646b193ebbfd084cdec437e75a7c592182

Эта сеть предлагает одно: образец, который собирается. Она запустила его в песочнице и сохранила подписанную квитанцию. Она ничего не оценивает и ничего не гарантирует — собирается ли тот же код у вас, она не измеряла. Сколько различных ключей подписи подали пройденную квитанцию контракта. Один — только автор; больше одного — значит, кто-то ещё тоже собрал. Ключ создаётся сам и не имеет зарегистрированной личности, поэтому считаются ключи, а не люди. MIT-0

Свидетельства выполнения

Заявленное окружение и подписанные запуски разделены, чтобы вы точно видели, что этот образец запускал и где.

Основа свидетельства
Подписанный контракт пройден
Квитанции проверки
1
Ключи подписи, собравшие его
1
Заявленная среда linux 24 · ubuntu · glibc 2.39 x64 go

Среды запусков проверки

Окружение Контракт Этапы Запуск
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-19

Кейс

HOW
Цель
verify golang.org/x/net/html/atom.Form in pkg:golang/golang.org/x/net@v0.0.0-20210525063256-abc453219eb5
Пакеты
Символы
  • golang.org/x/net/html/atom.Form
Создан
2026-10-19T17:31:52Z

Контракт

  1. atom.Form is a non-zero Atom constant representing the form HTML tag
  2. atom.Form.String() returns the lowercase string "form"
  3. atom.Lookup([]byte("form")) returns atom.Form
  4. atom.Lookup is case-sensitive and returns 0 for []byte("FORM")
  5. atom.String([]byte("form")) returns "form"
  6. atom.Form is distinct from atom.Input, atom.Div, and atom.Formaction
  7. html.NewTokenizer yields start and end tag tokens with DataAtom equal to atom.Form for a form element
  8. html.Parse produces an ElementNode with DataAtom equal to atom.Form for a form element

Файлы

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

Скачать артефакт с исходным кодом (tar.gz)

Исходный код

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.0.0-20210525063256-abc453219eb5
Kind: HOW

Use EXACTLY these public packages and versions:
  - pkg:golang/golang.org/x/net@v0.0.0-20210525063256-abc453219eb5
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:ffeb74bf32c4797b67f62c2827abe2a6ee2f2f5a39baa75a8cbf9fdf8bd41a49","contract":["atom.Form is a non-zero Atom constant representing the form HTML tag","atom.Form.String() returns the lowercase string \"form\"","atom.Lookup([]byte(\"form\")) returns atom.Form","atom.Lookup is case-sensitive and returns 0 for []byte(\"FORM\")","atom.String([]byte(\"form\")) returns \"form\"","atom.Form is distinct from atom.Input, atom.Div, and atom.Formaction","html.NewTokenizer yields start and end tag tokens with DataAtom equal to atom.Form for a form element","html.Parse produces 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.0.0-20210525063256-abc453219eb5","kind":"HOW","packages":["pkg:golang/golang.org/x/net@v0.0.0-20210525063256-abc453219eb5"],"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.0.0-20210525063256-abc453219eb5"],"schemaVersion":1,"subject":"pkg:golang/golang.org/x/net@v0.0.0-20210525063256-abc453219eb5","symbols":["golang.org/x/net/html/atom.Form"],"verifierAdapter":"golang@1"}
go.mod
module sample

go 1.21

require golang.org/x/net v0.0.0-20210525063256-abc453219eb5
go.sum
golang.org/x/net v0.0.0-20210525063256-abc453219eb5 h1:wjuX4b5yYQnEQHzd+CBcrcC6OVR2J1CN6mUy0oSxIPo=
golang.org/x/net v0.0.0-20210525063256-abc453219eb5/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y=
spec.json
{
  "schemaVersion": 1,
  "goal": "verify golang.org/x/net/html/atom.Form in pkg:golang/golang.org/x/net@v0.0.0-20210525063256-abc453219eb5",
  "kind": "HOW",
  "packages": [
    "pkg:golang/golang.org/x/net@v0.0.0-20210525063256-abc453219eb5"
  ],
  "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 assert(cond bool, msg string) {
	if !cond {
		fmt.Fprintln(os.Stderr, "assertion failed:", msg)
		os.Exit(1)
	}
}

func main() {
	// 1. atom.Form is a non-zero Atom constant representing the "form" HTML tag
	var formAtom atom.Atom = atom.Form
	assert(formAtom != 0, "atom.Form should be a non-zero Atom constant")

	// 2. atom.Form.String() returns the lowercase string "form"
	assert(formAtom.String() == "form", "atom.Form.String() should return \"form\"")

	// 3. atom.Lookup([]byte("form")) resolves to atom.Form
	assert(atom.Lookup([]byte("form")) == atom.Form, "atom.Lookup([]byte(\"form\")) should equal atom.Form")

	// 4. atom.Lookup is case-sensitive and returns 0 for uppercase "FORM"
	assert(atom.Lookup([]byte("FORM")) == 0, "atom.Lookup([]byte(\"FORM\")) should return 0")

	// 5. atom.String([]byte("form")) returns "form"
	assert(atom.String([]byte("form")) == "form", "atom.String([]byte(\"form\")) should return \"form\"")

	// 6. atom.Form is distinct from other form-related and block atoms
	assert(atom.Form != atom.Input, "atom.Form should be distinct from atom.Input")
	assert(atom.Form != atom.Div, "atom.Form should be distinct from atom.Div")
	assert(atom.Form != atom.Formaction, "atom.Form should be distinct from atom.Formaction")

	// 7. html.NewTokenizer sets Token.DataAtom to atom.Form when tokenizing a <form> start and end tag
	z := html.NewTokenizer(strings.NewReader(`<form action="/submit"><input type="text"></form>`))
	tt := z.Next()
	assert(tt == html.StartTagToken, "first token should be StartTagToken")
	tok := z.Token()
	assert(tok.DataAtom == atom.Form, "start tag Token.DataAtom should equal atom.Form")
	assert(tok.Data == "form", "start tag Token.Data should equal \"form\"")

	tt = z.Next()
	assert(tt == html.StartTagToken, "second token should be StartTagToken for input")
	assert(z.Token().DataAtom == atom.Input, "second token DataAtom should equal atom.Input")

	tt = z.Next()
	assert(tt == html.EndTagToken, "third token should be EndTagToken")
	endTok := z.Token()
	assert(endTok.DataAtom == atom.Form, "end tag Token.DataAtom should equal atom.Form")

	// 8. html.Parse sets Node.DataAtom to atom.Form on parsed <form> ElementNode
	doc, err := html.Parse(strings.NewReader(`<!DOCTYPE html><html><body><form id="f1"></form></body></html>`))
	assert(err == nil, "html.Parse should succeed without error")

	var foundForm bool
	var walk func(*html.Node)
	walk = func(n *html.Node) {
		if n.Type == html.ElementNode && n.DataAtom == atom.Form {
			foundForm = true
			assert(n.Data == "form", "parsed ElementNode with atom.Form should have Data == \"form\"")
		}
		for c := n.FirstChild; c != nil; c = c.NextSibling {
			walk(c)
		}
	}
	walk(doc)
	assert(foundForm, "html.Parse should produce an ElementNode with DataAtom == atom.Form")
}

Исходный сидер

аноним