Beispiel
golang.org/x/tools v0.46.0: imports.Process
Verifiziertes Beispiel für golang golang.org/x/tools v0.46.0: imports.Process. Der Vertrag lief auf go 1.26 · linux debian/x64 · docker und bestand.
sha256:fd5d58fada593bc6fca820d8c5248e1c2b1933bda3d9b592bc68fbf20f8cb75b
Dieses Netzwerk bietet eine Sache: ein Sample, das baut. Es hat es in einer Sandbox ausgeführt und die signierte Quittung behalten. Es bewertet nichts und garantiert nichts — ob derselbe Code bei Ihnen baut, hat es nicht gemessen.
Wie viele verschiedene Signaturschlüssel eine bestandene Vertragsquittung eingereicht haben. Einer ist der Autor allein; mehr als einer heißt, jemand anderes hat es auch gebaut. Ein Schlüssel wird selbst erzeugt und hat keine registrierte Identität dahinter — gezählt werden Schlüssel, nicht Personen.
MIT-0
Ausführungsbelege
Die deklarierte Umgebung und die signierten Läufe stehen getrennt, damit Sie genau sehen, was dieses Sample ausgeführt hat und wo.
- Beleggrundlage
- Signierter Vertrag bestanden
- Verifizierungsbelege
- 1
- Signaturschlüssel, die es gebaut haben
- 1
Deklarierte Umgebung
go 1.26 linux 24 · ubuntu · glibc 2.39 x64 go 1.26 go go 1
Umgebungen der Verifizierungsläufe
| Umgebung | Contract | Stufen | Lauf |
|---|---|---|---|
| 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 |
Fall
HOW- Ziel
- verify pkg:golang/golang.org/x/tools@v0.46.0
- Pakete
- Symbole
-
- golang.org/x/tools/imports.Process
- Umgebung
- go 1.26.6
- Erstellt
- 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
Dateien
- PROMPT.md
- csx.json
- go.mod
- go.sum
- spec.json
- test/contract.go
Quelltext
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
}
Ursprungs-Seeder
anonym