샘플
golang.org/x/tools v0.14.0
검증된 샘플 — golang golang.org/x/tools v0.14.0. go 1.26 · linux alpine/x64 · docker에서 contract를 실행해 통과했습니다: astutil.UsesImport determines whether an AST file…
sha256:443da86d1dcb258ef2be41587345fe68dec823a88187042d6c0b6a7df3ebd1eb
이 네트워크가 제공하는 것은 하나입니다. 빌드되는 샘플. 샌드박스에서 돌리고 서명된 영수증을 보관합니다. 등급을 매기지 않고 무엇도 보증하지 않습니다 — 같은 코드가 당신 환경에서 빌드되는지는 측정한 적이 없습니다.
통과한 계약 영수증을 낸 서로 다른 서명 키의 수입니다. 하나면 작성자 혼자이고, 둘 이상이면 다른 사람도 빌드했다는 뜻입니다. 키는 스스로 만드는 것이고 뒤에 등록된 신원이 없으므로, 세는 것은 사람이 아니라 키입니다.
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.14.0
- 생성일
- 2026-08-28T09:13:18Z
컨트랙트
- astutil.UsesImport determines whether an AST file contains references to an imported package
- astutil.PathEnclosingInterval identifies the AST node stack enclosing a token position range
- typeutil.IntuitiveMethodSet returns the method set of a type including promoted methods
- typeutil.MakeHasher creates a type hasher for consistent identity hashing across types
- typeutil.Dependencies computes the transitive dependencies of a set of packages
파일
- 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.14.0
Kind: HOW
Use EXACTLY these public packages and versions:
- pkg:golang/golang.org/x/tools@v0.14.0
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:87f31270e00d90fe31a84dd3ff730b58d7f09b302fe890c58e42d6939a178ffe","contract":["astutil.UsesImport determines whether an AST file contains references to an imported package","astutil.PathEnclosingInterval identifies the AST node stack enclosing a token position range","typeutil.IntuitiveMethodSet returns the method set of a type including promoted methods","typeutil.MakeHasher creates a type hasher for consistent identity hashing across types","typeutil.Dependencies computes the transitive dependencies of a set of packages"],"goal":"verify pkg:golang/golang.org/x/tools@v0.14.0","kind":"HOW","packages":["pkg:golang/golang.org/x/tools@v0.14.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.14.0"],"schemaVersion":1,"subject":"pkg:golang/golang.org/x/tools@v0.14.0","verifierAdapter":"golang@1"}
module sample-golang-tools
go 1.25.0
require golang.org/x/tools v0.14.0
golang.org/x/mod v0.13.0 h1:I/DsJXRlw/8l/0c24sM9yb0T4z9liZTduXvdAWYiysY=
golang.org/x/mod v0.13.0/go.mod h1:hTbmBsO62+eylJbnUtE2MGJUyE7QWk4xUqPFrRgJ+7c=
golang.org/x/sys v0.13.0 h1:Af8nKPmuFypiUBjVoU9V20FiaFXOcuZI21p0ycVYYGE=
golang.org/x/sys v0.13.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/tools v0.14.0 h1:jvNa2pY0M4r62jkRQ6RwEZZyPcymeL9XZMLBbV7U2nc=
golang.org/x/tools v0.14.0/go.mod h1:uYBEerGOWcJyEORxN+Ek8+TT266gXkNlHdJBwexUsBg=
package main
import (
"fmt"
"go/parser"
"go/token"
"go/types"
"golang.org/x/tools/go/ast/astutil"
"golang.org/x/tools/go/types/typeutil"
)
func main() {
src := `package main
import "fmt"
func hello() {
fmt.Println("hello world")
}`
fset := token.NewFileSet()
file, err := parser.ParseFile(fset, "hello.go", src, 0)
if err != nil {
panic(err)
}
// 1. astutil.UsesImport
usesFmt := astutil.UsesImport(file, "fmt")
fmt.Printf("Uses import fmt: %v\n", usesFmt)
// 2. astutil.PathEnclosingInterval
path, exact := astutil.PathEnclosingInterval(file, file.Pos(), file.End())
fmt.Printf("Enclosing nodes: %d, exact: %v\n", len(path), exact)
// 3. typeutil.MakeHasher
hasher := typeutil.MakeHasher()
intType := types.Typ[types.Int]
hashVal := hasher.Hash(intType)
fmt.Printf("Int type hash: %d\n", hashVal)
// 4. typeutil.IntuitiveMethodSet
mset := typeutil.IntuitiveMethodSet(intType, nil)
fmt.Printf("Int method count: %d\n", len(mset))
// 5. typeutil.Dependencies
pkg := types.NewPackage("example/pkg", "pkg")
deps := typeutil.Dependencies(pkg)
fmt.Printf("Dependencies count: %d\n", len(deps))
}
{
"schemaVersion": 1,
"goal": "verify pkg:golang/golang.org/x/tools@v0.14.0",
"kind": "HOW",
"packages": [
"pkg:golang/golang.org/x/tools@v0.14.0"
]
}
package main
import (
"fmt"
"go/ast"
"go/parser"
"go/token"
"go/types"
"os"
"golang.org/x/tools/go/ast/astutil"
"golang.org/x/tools/go/types/typeutil"
)
func main() {
// Assertion 1: astutil.UsesImport determines whether an AST file contains references to an imported package
{
src := `package main
import "fmt"
func hello() {
fmt.Println("test")
}`
fset := token.NewFileSet()
file, err := parser.ParseFile(fset, "src.go", src, 0)
if err != nil {
fmt.Fprintf(os.Stderr, "FAIL: parser.ParseFile error: %v\n", err)
os.Exit(1)
}
if !astutil.UsesImport(file, "fmt") {
fmt.Fprintln(os.Stderr, "FAIL: astutil.UsesImport returned false for used import 'fmt'")
os.Exit(1)
}
if astutil.UsesImport(file, "os") {
fmt.Fprintln(os.Stderr, "FAIL: astutil.UsesImport returned true for unused package 'os'")
os.Exit(1)
}
}
// Assertion 2: astutil.PathEnclosingInterval identifies the AST node stack enclosing a token position range
{
src := `package main
func targetFunc() int {
return 42
}`
fset := token.NewFileSet()
file, err := parser.ParseFile(fset, "target.go", src, 0)
if err != nil {
fmt.Fprintf(os.Stderr, "FAIL: parser.ParseFile error: %v\n", err)
os.Exit(1)
}
// Find position of FuncDecl
var targetPos token.Pos
ast.Inspect(file, func(n ast.Node) bool {
if fd, ok := n.(*ast.FuncDecl); ok && fd.Name.Name == "targetFunc" {
targetPos = fd.Name.Pos()
return false
}
return true
})
if !targetPos.IsValid() {
fmt.Fprintln(os.Stderr, "FAIL: targetFunc position not found")
os.Exit(1)
}
path, exact := astutil.PathEnclosingInterval(file, targetPos, targetPos)
if !exact || len(path) == 0 {
fmt.Fprintf(os.Stderr, "FAIL: astutil.PathEnclosingInterval exact=%v, len(path)=%d\n", exact, len(path))
os.Exit(1)
}
ident, ok := path[0].(*ast.Ident)
if !ok || ident.Name != "targetFunc" {
fmt.Fprintf(os.Stderr, "FAIL: innermost node expected *ast.Ident 'targetFunc', got %T\n", path[0])
os.Exit(1)
}
_, isFile := path[len(path)-1].(*ast.File)
if !isFile {
fmt.Fprintf(os.Stderr, "FAIL: outermost node expected *ast.File, got %T\n", path[len(path)-1])
os.Exit(1)
}
}
// Assertion 3: typeutil.IntuitiveMethodSet returns the method set of a type including promoted methods
{
pkg := types.NewPackage("example/types", "types")
innerStruct := types.NewStruct(nil, nil)
innerNamed := types.NewNamed(types.NewTypeName(token.NoPos, pkg, "Inner", nil), innerStruct, nil)
recvVar := types.NewVar(token.NoPos, pkg, "recv", innerNamed)
sig := types.NewSignatureType(recvVar, nil, nil, nil, nil, false)
innerMethod := types.NewFunc(token.NoPos, pkg, "DoWork", sig)
innerNamed.AddMethod(innerMethod)
outerField := types.NewField(token.NoPos, pkg, "Inner", innerNamed, true) // embedded field
outerStruct := types.NewStruct([]*types.Var{outerField}, nil)
outerNamed := types.NewNamed(types.NewTypeName(token.NoPos, pkg, "Outer", nil), outerStruct, nil)
mset := typeutil.IntuitiveMethodSet(outerNamed, nil)
found := false
for _, sel := range mset {
if sel.Obj().Name() == "DoWork" {
found = true
break
}
}
if !found {
fmt.Fprintln(os.Stderr, "FAIL: typeutil.IntuitiveMethodSet did not find promoted method 'DoWork'")
os.Exit(1)
}
}
// Assertion 4: typeutil.MakeHasher creates a type hasher for consistent identity hashing across types
{
hasher := typeutil.MakeHasher()
slice1 := types.NewSlice(types.Typ[types.Int])
slice2 := types.NewSlice(types.Typ[types.Int])
slice3 := types.NewSlice(types.Typ[types.String])
h1 := hasher.Hash(slice1)
h2 := hasher.Hash(slice2)
h3 := hasher.Hash(slice3)
if h1 != h2 {
fmt.Fprintf(os.Stderr, "FAIL: typeutil.MakeHasher expected identical hashes for identical slice types: %d != %d\n", h1, h2)
os.Exit(1)
}
if h1 == h3 {
fmt.Fprintf(os.Stderr, "FAIL: typeutil.MakeHasher expected different hashes for distinct types: %d == %d\n", h1, h3)
os.Exit(1)
}
}
// Assertion 5: typeutil.Dependencies computes the transitive dependencies of a set of packages
{
pkgC := types.NewPackage("example/pkgC", "pkgC")
pkgB := types.NewPackage("example/pkgB", "pkgB")
pkgB.SetImports([]*types.Package{pkgC})
pkgA := types.NewPackage("example/pkgA", "pkgA")
pkgA.SetImports([]*types.Package{pkgB})
deps := typeutil.Dependencies(pkgA)
if len(deps) != 3 {
fmt.Fprintf(os.Stderr, "FAIL: typeutil.Dependencies expected 3 packages, got %d\n", len(deps))
os.Exit(1)
}
paths := make([]string, len(deps))
for i, p := range deps {
paths[i] = p.Path()
}
// Topological order: pkgC, pkgB, pkgA
if paths[0] != "example/pkgC" || paths[1] != "example/pkgB" || paths[2] != "example/pkgA" {
fmt.Fprintf(os.Stderr, "FAIL: typeutil.Dependencies topological order mismatch: %v\n", paths)
os.Exit(1)
}
}
fmt.Println("PASS: golang.org/x/tools contract passed")
}
오리진 시더
익명