Sample
golang.org/x/tools v0.46.0: imports.Process
Verified sample for golang golang.org/x/tools v0.46.0: imports.Process. The contract ran on go 1.26 · linux debian/x64 · docker and passed.
sha256:fd5d58fada593bc6fca820d8c5248e1c2b1933bda3d9b592bc68fbf20f8cb75b
This network offers one thing: a sample that builds. It ran the sample in a sandbox and kept the signed receipt. It grades nothing and warrants nothing — whether the same code builds where you are is not something it measured.
How many distinct signing keys filed a passing contract receipt. One is the author alone; more than one means somebody else built it too. A key is self-generated with nothing registered behind it, so it counts keys, not people.
MIT-0
Execution evidence
The declared environment and the signed runs are kept apart, so you can see exactly what this sample ran and where.
- Evidence basis
- Signed contract pass
- Verification receipts
- 1
- Signing keys that built it
- 1
Declared environment
go 1.26 linux 24 · ubuntu · glibc 2.39 x64 go 1.26 go go 1
Verification-run environments
| Environment | Contract | Stages | Run |
|---|---|---|---|
| go 1.26 · linux debian/x64 · docker ed25519:c1973797be207ac4 | PASS | compile:PASS · contract:PASS · load:PASS · resolve:PASS CONTAINER_RUN · golang@1golang:1.26@sha256:e30143be198a… |
2026-10-17 |
Case
HOW- Goal
- verify pkg:golang/golang.org/x/tools@v0.46.0
- Packages
- Symbols
-
- golang.org/x/tools/imports.Process
- Environment
- go 1.26.6
- Created
- 2026-10-17T09:16:00Z
Contract
- imports.Process automatically inserts missing standard library imports for referenced symbols
- imports.Process automatically removes unused imports from Go source code
- imports.Process formats and canonicalizes Go source code when nil Options is provided
- imports.Process with Options.FormatOnly true formats source code without adding or removing imports
- imports.Process with Options.Fragment true processes declaration fragments without a package clause
- imports.Process returns an error when given invalid Go syntax that cannot be parsed
Files
- PROMPT.md
- csx.json
- go.mod
- go.sum
- spec.json
- test/contract.go
Source
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.46.0
Kind: HOW
Use EXACTLY these public packages and versions:
- pkg:golang/golang.org/x/tools@v0.46.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.
{"buildCommand":["go","build","-ldflags=-w -s","-o","testbin","./test"],"case":{"caseId":"case:sha256:305eeb94ab88b310c8772c846f8bdce30c58689446ab2cf6a7b4019cd77ad6a5","contract":["imports.Process automatically inserts missing standard library imports for referenced symbols","imports.Process automatically removes unused imports from Go source code","imports.Process formats and canonicalizes Go source code when nil Options is provided","imports.Process with Options.FormatOnly true formats source code without adding or removing imports","imports.Process with Options.Fragment true processes declaration fragments without a package clause","imports.Process returns an error when given invalid Go syntax that cannot be parsed"],"goal":"verify pkg:golang/golang.org/x/tools@v0.46.0","kind":"HOW","packages":["pkg:golang/golang.org/x/tools@v0.46.0"],"schemaVersion":1,"symbols":["golang.org/x/tools/imports.Process"]},"contractCommand":["./testbin"],"environment":{"arch":"x64","distro":"ubuntu","ecosystem":"golang","language":"go","libc":"glibc","libcVersion":"2.39","os":"linux","osVersionBucket":"24","packageManager":"go","packageManagerVersion":"1.26.6","runtime":"go","runtimeVersion":"1.26.6","schemaVersion":1},"license":"MIT-0","packages":["pkg:golang/golang.org/x/tools@v0.46.0"],"schemaVersion":1,"subject":"pkg:golang/golang.org/x/tools@v0.46.0","symbols":["golang.org/x/tools/imports.Process"],"verifierAdapter":"golang@1"}
module sample
go 1.26.6
require golang.org/x/tools v0.46.0
require (
golang.org/x/mod v0.37.0 // indirect
golang.org/x/sync v0.21.0 // indirect
)
github.com/google/go-cmp v0.6.0 h1:ofyhxvXcZhMsU5ulbFiLKl/XBFqE1GSq7atu8tAmTRI=
github.com/google/go-cmp v0.6.0/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY=
golang.org/x/mod v0.37.0 h1:vF1DjpVEshcIqoEaauuHebaLk1O1forxjxBaVn884JQ=
golang.org/x/mod v0.37.0/go.mod h1:m8S8VeM9r4dzDwjrKO0a1sZP3YjeMamRRlD+fmR2Q/0=
golang.org/x/sync v0.21.0 h1:HLII4xRRTtCRkxYp4HNFF0Js/Og6q2i++KXbg0gHCwM=
golang.org/x/sync v0.21.0/go.mod h1:9xrNwdLfx4jkKbNva9FpL6vEN7evnE43NNNJQ2LF3+0=
golang.org/x/tools v0.46.0 h1:7jTurBkPZu4moS/Uy4OQT1M+QBlsj3wejyZwsT8Z7rk=
golang.org/x/tools v0.46.0/go.mod h1:FrD85F8l+NWL+9XWBSyVSHO6Ne4jutsfIFba7AWQ5Ys=
{
"schemaVersion": 1,
"goal": "verify pkg:golang/golang.org/x/tools@v0.46.0",
"kind": "HOW",
"packages": [
"pkg:golang/golang.org/x/tools@v0.46.0"
]
}
package main
import (
"fmt"
"os"
"strings"
"golang.org/x/tools/imports"
)
func main() {
if err := verifyContract(); err != nil {
fmt.Fprintf(os.Stderr, "Contract verification failed: %v\n", err)
os.Exit(1)
}
fmt.Println("All contract assertions passed.")
}
func verifyContract() error {
// 1. imports.Process automatically inserts missing standard library imports for referenced symbols
{
src := []byte("package main\n\nfunc main() {\n\tfmt.Println(\"hello\")\n}\n")
res, err := imports.Process("main.go", src, nil)
if err != nil {
return fmt.Errorf("assertion 1 failed: %w", err)
}
out := string(res)
if !strings.Contains(out, `"fmt"`) {
return fmt.Errorf("assertion 1: expected fmt import to be added, got:\n%s", out)
}
}
// 2. imports.Process automatically removes unused imports from Go source code
{
src := []byte("package main\n\nimport (\n\t\"os\"\n\t\"strings\"\n)\n\nfunc main() {\n\t_ = strings.ToUpper(\"abc\")\n}\n")
res, err := imports.Process("main.go", src, nil)
if err != nil {
return fmt.Errorf("assertion 2 failed: %w", err)
}
out := string(res)
if strings.Contains(out, `"os"`) {
return fmt.Errorf("assertion 2: expected unused os import to be removed, got:\n%s", out)
}
if !strings.Contains(out, `"strings"`) {
return fmt.Errorf("assertion 2: expected used strings import to remain, got:\n%s", out)
}
}
// 3. imports.Process formats and canonicalizes Go source code when nil Options is provided
{
src := []byte("package main\n\nfunc compute( x,y int )int{return x+y}\n")
res, err := imports.Process("main.go", src, nil)
if err != nil {
return fmt.Errorf("assertion 3 failed: %w", err)
}
expected := "package main\n\nfunc compute(x, y int) int { return x + y }\n"
if string(res) != expected {
return fmt.Errorf("assertion 3: expected %q, got %q", expected, string(res))
}
}
// 4. imports.Process with Options.FormatOnly true formats source code without adding or removing imports
{
src := []byte("package main\n\nimport \"os\"\n\nfunc main() {\n\tfmt.Println( \"unimported\" )\n}\n")
opt := &imports.Options{
FormatOnly: true,
Comments: true,
TabIndent: true,
TabWidth: 8,
}
res, err := imports.Process("main.go", src, opt)
if err != nil {
return fmt.Errorf("assertion 4 failed: %w", err)
}
out := string(res)
if !strings.Contains(out, `import "os"`) {
return fmt.Errorf("assertion 4: expected unused os import to remain when FormatOnly is true, got:\n%s", out)
}
if strings.Contains(out, `"fmt"`) {
return fmt.Errorf("assertion 4: expected missing fmt import not to be added when FormatOnly is true, got:\n%s", out)
}
if !strings.Contains(out, `fmt.Println("unimported")`) {
return fmt.Errorf("assertion 4: expected code formatting to be applied, got:\n%s", out)
}
}
// 5. imports.Process with Options.Fragment true processes declaration fragments without a package clause
{
src := []byte("func helper() {\nfmt.Println(\"fragment\")\n}\n")
opt := &imports.Options{
Fragment: true,
Comments: true,
TabIndent: true,
TabWidth: 8,
}
res, err := imports.Process("fragment.go", src, opt)
if err != nil {
return fmt.Errorf("assertion 5 failed: %w", err)
}
out := string(res)
if !strings.Contains(out, `import "fmt"`) {
return fmt.Errorf("assertion 5: expected fmt import for fragment, got:\n%s", out)
}
if !strings.Contains(out, "func helper() {\n\tfmt.Println(\"fragment\")\n}") {
return fmt.Errorf("assertion 5: unexpected formatted fragment:\n%s", out)
}
}
// 6. imports.Process returns an error when given invalid Go syntax that cannot be parsed
{
src := []byte("package main\n\nfunc broken( {\n")
_, err := imports.Process("broken.go", src, nil)
if err == nil {
return fmt.Errorf("assertion 6: expected syntax error for invalid Go code, got nil")
}
}
return nil
}
Origin Seeder
anonymous