Пример
golang.org/x/tools v0.44.0
Проверенный пример — golang golang.org/x/tools v0.44.0. Контракт выполнен на go 1.26 · linux alpine/x64 · docker и пройден: txtar.Parse parses…
sha256:12ba36a4332e2b9b2e7eb13365e790abafeb4ea1e09594ff445aed029f31caea
Эта сеть предлагает одно: образец, который собирается. Она запустила его в песочнице и сохранила подписанную квитанцию. Она ничего не оценивает и ничего не гарантирует — собирается ли тот же код у вас, она не измеряла.
Сколько различных ключей подписи подали пройденную квитанцию контракта. Один — только автор; больше одного — значит, кто-то ещё тоже собрал. Ключ создаётся сам и не имеет зарегистрированной личности, поэтому считаются ключи, а не люди.
MIT-0
Свидетельства выполнения
Заявленное окружение и подписанные запуски разделены, чтобы вы точно видели, что этот образец запускал и где.
- Основа свидетельства
- Подписанный контракт пройден
- Квитанции проверки
- 1
- Ключи подписи, собравшие его
- 1
Заявленная среда
linux 24 · ubuntu · glibc 2.39 x64 go
Среды запусков проверки
| Окружение | Контракт | Этапы | Запуск |
|---|---|---|---|
| go 1.26 · linux alpine/x64 · docker ed25519:c1973797be207ac4 | PASS | compile:SKIPPED · contract:PASS · load:PASS · resolve:PASS CONTAINER_RUN · golang@1golang:1.26-alpine@sha256:28d89ee9cc0f… |
2026-08-28 |
Кейс
HOW- Цель
- verify pkg:golang/golang.org/x/tools@v0.44.0
- Пакеты
- Создан
- 2026-08-28T08:30:15Z
Контракт
- txtar.Parse parses txtar-formatted byte data into an Archive with comment and file entries
- txtar.Format serializes an Archive back into byte data preserving file boundaries and content
- astutil.Apply traverses AST nodes invoking pre and post functions and allows node inspection
- astutil.AddImport adds an import specification to an AST file
- astutil.DeleteImport removes an existing import specification from an AST file
- astutil.RewriteImport rewrites import path from old path to new path in an AST file
Файлы
- PROMPT.md
- csx.json
- go.mod
- go.sum
- main.go
- spec.json
- test/contract.go
Исходный код
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 pkg:golang/golang.org/x/tools@v0.44.0
Kind: HOW
Use EXACTLY these public packages and versions:
- pkg:golang/golang.org/x/tools@v0.44.0
Constraints:
- executionContext: node
Required runtime conditions:
- ecosystem: npm
- language: javascript
- moduleSystem: cjs
- packageManager: npm@10.9.8
- runtime: node@22.23.2
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:f58131f28077243d84437b38274cda13bcd7624a0dc750ec67c756d8c85d45ad","contract":["txtar.Parse parses txtar-formatted byte data into an Archive with comment and file entries","txtar.Format serializes an Archive back into byte data preserving file boundaries and content","astutil.Apply traverses AST nodes invoking pre and post functions and allows node inspection","astutil.AddImport adds an import specification to an AST file","astutil.DeleteImport removes an existing import specification from an AST file","astutil.RewriteImport rewrites import path from old path to new path in an AST file"],"goal":"verify pkg:golang/golang.org/x/tools@v0.44.0","kind":"HOW","packages":["pkg:golang/golang.org/x/tools@v0.44.0"],"schemaVersion":1},"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/tools@v0.44.0"],"schemaVersion":1,"subject":"pkg:golang/golang.org/x/tools@v0.44.0","verifierAdapter":"golang@1"}
module sample-golang-tools
go 1.26.6
require golang.org/x/tools v0.44.0
golang.org/x/tools v0.44.0 h1:UP4ajHPIcuMjT1GqzDWRlalUEoY+uzoZKnhOjbIPD2c=
golang.org/x/tools v0.44.0/go.mod h1:KA0AfVErSdxRZIsOVipbv3rQhVXTnlU6UhKxHd1seDI=
package main
import (
"fmt"
"go/parser"
"go/token"
"golang.org/x/tools/go/ast/astutil"
"golang.org/x/tools/txtar"
)
func main() {
// Parse a txtar archive
raw := []byte("Header comment\n-- file.txt --\nSample data\n")
archive := txtar.Parse(raw)
fmt.Printf("Archive comment: %s, files count: %d\n", string(archive.Comment), len(archive.Files))
// Format txtar archive
formatted := txtar.Format(archive)
fmt.Printf("Formatted size: %d bytes\n", len(formatted))
// Manipulate Go AST imports
fset := token.NewFileSet()
f, err := parser.ParseFile(fset, "example.go", "package main\nfunc run() {}", 0)
if err == nil {
astutil.AddImport(fset, f, "fmt")
fmt.Printf("Package name: %s, imports count: %d\n", f.Name.Name, len(f.Imports))
}
}
{
"schemaVersion": 1,
"goal": "verify pkg:golang/golang.org/x/tools@v0.44.0",
"kind": "HOW",
"packages": [
"pkg:golang/golang.org/x/tools@v0.44.0"
],
"constraints": {
"executionContext": "node"
},
"runtimeConditions": {
"ecosystem": "npm",
"language": "javascript",
"moduleSystem": "cjs",
"packageManager": "npm@10.9.8",
"runtime": "node@22.23.2"
}
}
package main
import (
"fmt"
"go/parser"
"go/token"
"os"
"golang.org/x/tools/go/ast/astutil"
"golang.org/x/tools/txtar"
)
func main() {
// Assertion 1: txtar.Parse parses txtar-formatted byte data into an Archive with comment and file entries
{
archiveData := []byte("Archive comment header\n-- file1.txt --\nHello from file 1\n-- sub/file2.txt --\nLine 1\nLine 2\n")
archive := txtar.Parse(archiveData)
if archive == nil {
fmt.Fprintln(os.Stderr, "FAIL: txtar.Parse returned nil archive")
os.Exit(1)
}
if string(archive.Comment) != "Archive comment header\n" {
fmt.Fprintf(os.Stderr, "FAIL: txtar.Parse unexpected comment: %q\n", string(archive.Comment))
os.Exit(1)
}
if len(archive.Files) != 2 {
fmt.Fprintf(os.Stderr, "FAIL: txtar.Parse expected 2 files, got %d\n", len(archive.Files))
os.Exit(1)
}
if archive.Files[0].Name != "file1.txt" || string(archive.Files[0].Data) != "Hello from file 1\n" {
fmt.Fprintf(os.Stderr, "FAIL: txtar.Parse unexpected file1 content: name=%q data=%q\n", archive.Files[0].Name, string(archive.Files[0].Data))
os.Exit(1)
}
if archive.Files[1].Name != "sub/file2.txt" || string(archive.Files[1].Data) != "Line 1\nLine 2\n" {
fmt.Fprintf(os.Stderr, "FAIL: txtar.Parse unexpected file2 content: name=%q data=%q\n", archive.Files[1].Name, string(archive.Files[1].Data))
os.Exit(1)
}
}
// Assertion 2: txtar.Format serializes an Archive back into byte data preserving file boundaries and content
{
archive := &txtar.Archive{
Comment: []byte("Sample comment\n"),
Files: []txtar.File{
{Name: "data.json", Data: []byte("{\"ok\":true}\n")},
{Name: "readme.txt", Data: []byte("Sample readme text\n")},
},
}
formatted := txtar.Format(archive)
expected := "Sample comment\n-- data.json --\n{\"ok\":true}\n-- readme.txt --\nSample readme text\n"
if string(formatted) != expected {
fmt.Fprintf(os.Stderr, "FAIL: txtar.Format mismatch:\ngot:\n%s\nexpected:\n%s\n", string(formatted), expected)
os.Exit(1)
}
}
// Assertion 3: astutil.Apply traverses AST nodes invoking pre and post functions and allows node inspection
{
src := `package main
import "fmt"
func main() {
fmt.Println("test")
}`
fset := token.NewFileSet()
file, err := parser.ParseFile(fset, "src.go", src, parser.ParseComments)
if err != nil {
fmt.Fprintf(os.Stderr, "FAIL: parser.ParseFile failed: %v\n", err)
os.Exit(1)
}
visitedPre := 0
visitedPost := 0
astutil.Apply(file, func(c *astutil.Cursor) bool {
if c.Node() != nil {
visitedPre++
}
return true
}, func(c *astutil.Cursor) bool {
if c.Node() != nil {
visitedPost++
}
return true
})
if visitedPre == 0 || visitedPre != visitedPost {
fmt.Fprintf(os.Stderr, "FAIL: astutil.Apply visit count mismatch: pre=%d post=%d\n", visitedPre, visitedPost)
os.Exit(1)
}
}
// Assertion 4: astutil.AddImport adds an import specification to an AST file
{
src := `package main
func hello() {}`
fset := token.NewFileSet()
file, err := parser.ParseFile(fset, "src.go", src, 0)
if err != nil {
fmt.Fprintf(os.Stderr, "FAIL: parser.ParseFile failed: %v\n", err)
os.Exit(1)
}
added := astutil.AddImport(fset, file, "strings")
if !added {
fmt.Fprintln(os.Stderr, "FAIL: astutil.AddImport returned false for new import")
os.Exit(1)
}
found := false
for _, imp := range file.Imports {
if imp.Path.Value == `"strings"` {
found = true
break
}
}
if !found {
fmt.Fprintln(os.Stderr, "FAIL: astutil.AddImport did not add import to file.Imports")
os.Exit(1)
}
}
// Assertion 5: astutil.DeleteImport removes an existing import specification from an AST file
{
src := `package main
import (
"fmt"
"strings"
)
func hello() {}`
fset := token.NewFileSet()
file, err := parser.ParseFile(fset, "src.go", src, 0)
if err != nil {
fmt.Fprintf(os.Stderr, "FAIL: parser.ParseFile failed: %v\n", err)
os.Exit(1)
}
deleted := astutil.DeleteImport(fset, file, "fmt")
if !deleted {
fmt.Fprintln(os.Stderr, "FAIL: astutil.DeleteImport returned false for existing import")
os.Exit(1)
}
for _, imp := range file.Imports {
if imp.Path.Value == `"fmt"` {
fmt.Fprintln(os.Stderr, "FAIL: astutil.DeleteImport failed to remove import")
os.Exit(1)
}
}
}
// Assertion 6: astutil.RewriteImport rewrites import path from old path to new path in an AST file
{
src := `package main
import "old/path"
func hello() {}`
fset := token.NewFileSet()
file, err := parser.ParseFile(fset, "src.go", src, 0)
if err != nil {
fmt.Fprintf(os.Stderr, "FAIL: parser.ParseFile failed: %v\n", err)
os.Exit(1)
}
rewritten := astutil.RewriteImport(fset, file, "old/path", "new/path")
if !rewritten {
fmt.Fprintln(os.Stderr, "FAIL: astutil.RewriteImport returned false")
os.Exit(1)
}
found := false
for _, imp := range file.Imports {
if imp.Path.Value == `"new/path"` {
found = true
break
}
}
if !found {
fmt.Fprintln(os.Stderr, "FAIL: astutil.RewriteImport did not update to new path")
os.Exit(1)
}
}
fmt.Println("PASS: golang.org/x/tools@v0.44.0 contract passed")
}
Исходный сидер
аноним