Exemple
golang.org/x/term v0.0.0-20210927222741-03fcf44c2211: IsTerminal
Échantillon vérifié pour golang golang.org/x/term v0.0.0-20210927222741-03fcf44c2211: IsTerminal. Le contrat s'est exécuté sur go 1.26 · linux alpine/x64 …
sha256:38c145bd2255afe98fbcf0759d22bdc628680de1feea8c5b169042b4eeeddb22
Ce réseau offre une seule chose : un échantillon qui compile. Il l'a exécuté dans un bac à sable et conservé le reçu signé. Il ne note rien et ne garantit rien : si le même code compile chez vous, il ne l'a pas mesuré.
Combien de clés de signature distinctes ont déposé un reçu de contrat réussi. Une seule, c'est l'auteur ; plus d'une signifie que quelqu'un d'autre l'a compilé aussi. Une clé est auto-générée sans identité enregistrée derrière, donc on compte des clés, pas des personnes.
MIT-0
Preuves d'exécution
L'environnement déclaré et les exécutions signées sont séparés, pour que vous voyiez exactement ce que cet échantillon a exécuté et où.
- Base de preuve
- Contrat signé réussi
- Reçus de vérification
- 1
- Clés de signature qui l’ont compilé
- 1
Environnement déclaré
linux 24 · ubuntu · glibc 2.39 x64 go
Environnements des exécutions de vérification
| Environnement | Contrat | Étapes | Exécution |
|---|---|---|---|
| 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-29 |
Cas
HOW- Objectif
- verify term.IsTerminal in pkg:golang/golang.org/x/term@v0.0.0-20210927222741-03fcf44c2211
- Symboles
-
- term.IsTerminal
- Créé
- 2026-08-29T14:03:53Z
Contrat
- term.IsTerminal returns false for invalid file descriptors
- term.IsTerminal returns false for regular file descriptors
- term.IsTerminal returns false for pipe file descriptors
- term.IsTerminal evaluates standard stream file descriptors without panicking
Fichiers
- PROMPT.md
- csx.json
- go.mod
- go.sum
- main.go
- spec.json
- test/contract.go
Code 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 term.IsTerminal in pkg:golang/golang.org/x/term@v0.0.0-20210927222741-03fcf44c2211
Kind: HOW
Use EXACTLY these public packages and versions:
- pkg:golang/golang.org/x/term@v0.0.0-20210927222741-03fcf44c2211
Demonstrate these symbols/APIs:
- term.IsTerminal
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:9758649c2562b71492f13867887dbdfaebc975602ef89d1c607d4895070e6f40","contract":["term.IsTerminal returns false for invalid file descriptors","term.IsTerminal returns false for regular file descriptors","term.IsTerminal returns false for pipe file descriptors","term.IsTerminal evaluates standard stream file descriptors without panicking"],"goal":"verify term.IsTerminal in pkg:golang/golang.org/x/term@v0.0.0-20210927222741-03fcf44c2211","kind":"HOW","packages":["pkg:golang/golang.org/x/term@v0.0.0-20210927222741-03fcf44c2211"],"schemaVersion":1,"symbols":["term.IsTerminal"]},"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/term@v0.0.0-20210927222741-03fcf44c2211"],"schemaVersion":1,"subject":"pkg:golang/golang.org/x/term@v0.0.0-20210927222741-03fcf44c2211","symbols":["term.IsTerminal"],"verifierAdapter":"golang@1"}
module example.com/sample
go 1.26.0
require golang.org/x/term v0.0.0-20210927222741-03fcf44c2211
require golang.org/x/sys v0.0.0-20210615035016-665e8c7367d1 // indirect
golang.org/x/sys v0.0.0-20210615035016-665e8c7367d1 h1:SrN+KX8Art/Sf4HNj6Zcz06G7VEz+7w9tdXTPOZ7+l4=
golang.org/x/sys v0.0.0-20210615035016-665e8c7367d1/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/term v0.0.0-20210927222741-03fcf44c2211 h1:JGgROgKl9N8DuW20oFS5gxc+lE67/N3FcwmBPMe7ArY=
golang.org/x/term v0.0.0-20210927222741-03fcf44c2211/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8=
package main
import (
"fmt"
"os"
"golang.org/x/term"
)
// CheckTerminal checks whether the provided file descriptor refers to a terminal.
func CheckTerminal(fd int) bool {
return term.IsTerminal(fd)
}
func main() {
stdinFd := int(os.Stdin.Fd())
stdoutFd := int(os.Stdout.Fd())
stderrFd := int(os.Stderr.Fd())
fmt.Printf("Stdin (fd=%d) is terminal: %v\n", stdinFd, CheckTerminal(stdinFd))
fmt.Printf("Stdout (fd=%d) is terminal: %v\n", stdoutFd, CheckTerminal(stdoutFd))
fmt.Printf("Stderr (fd=%d) is terminal: %v\n", stderrFd, CheckTerminal(stderrFd))
fmt.Printf("Invalid fd (-1) is terminal: %v\n", CheckTerminal(-1))
}
{
"schemaVersion": 1,
"goal": "verify term.IsTerminal in pkg:golang/golang.org/x/term@v0.0.0-20210927222741-03fcf44c2211",
"kind": "HOW",
"packages": [
"pkg:golang/golang.org/x/term@v0.0.0-20210927222741-03fcf44c2211"
],
"symbols": [
"term.IsTerminal"
]
}
package main
import (
"fmt"
"os"
"golang.org/x/term"
)
func main() {
// Assertion 1: term.IsTerminal returns false for invalid file descriptors
if term.IsTerminal(-1) {
fmt.Fprintf(os.Stderr, "FAIL: expected false for fd=-1, got true\n")
os.Exit(1)
}
if term.IsTerminal(-999) {
fmt.Fprintf(os.Stderr, "FAIL: expected false for fd=-999, got true\n")
os.Exit(1)
}
// Assertion 2: term.IsTerminal returns false for regular file descriptors
tmpFile, err := os.CreateTemp("", "contract_term_test_*")
if err != nil {
fmt.Fprintf(os.Stderr, "FAIL: failed to create temporary file: %v\n", err)
os.Exit(1)
}
defer os.Remove(tmpFile.Name())
defer tmpFile.Close()
if term.IsTerminal(int(tmpFile.Fd())) {
fmt.Fprintf(os.Stderr, "FAIL: expected false for regular file fd, got true\n")
os.Exit(1)
}
// Assertion 3: term.IsTerminal returns false for pipe file descriptors
r, w, err := os.Pipe()
if err != nil {
fmt.Fprintf(os.Stderr, "FAIL: failed to create pipe: %v\n", err)
os.Exit(1)
}
defer r.Close()
defer w.Close()
if term.IsTerminal(int(r.Fd())) {
fmt.Fprintf(os.Stderr, "FAIL: expected false for pipe reader fd, got true\n")
os.Exit(1)
}
if term.IsTerminal(int(w.Fd())) {
fmt.Fprintf(os.Stderr, "FAIL: expected false for pipe writer fd, got true\n")
os.Exit(1)
}
// Assertion 4: term.IsTerminal evaluates standard stream file descriptors without panicking
_ = term.IsTerminal(int(os.Stdin.Fd()))
_ = term.IsTerminal(int(os.Stdout.Fd()))
_ = term.IsTerminal(int(os.Stderr.Fd()))
fmt.Println("PASS: term.IsTerminal contract verified")
}
Seeder d'origine
anonyme