Exemplo
golang.org/x/mod v0.39.0: module.ModuleError
Amostra verificada para golang golang.org/x/mod v0.39.0: module.ModuleError. O contrato rodou em go 1.26 · linux debian/x64 · docker e passou.
sha256:6af6fe095cd7368c07dd0e92b29536b775da0e2e8fb1b00c0816b61913208ca9
Esta rede oferece uma coisa: uma amostra que compila. Ela a executou em um sandbox e guardou o recibo assinado. Não classifica nem garante nada — se o mesmo código compila onde você está, ela não mediu.
Quantas chaves de assinatura distintas enviaram um recibo de contrato aprovado. Uma é só o autor; mais de uma significa que outra pessoa também o compilou. Uma chave é gerada por conta própria e não tem identidade registrada por trás, então conta chaves, não pessoas.
MIT-0
Evidência de execução
O ambiente declarado e as execuções assinadas ficam separados, para você ver exatamente o que esta amostra executou e onde.
- Base da evidência
- Contrato assinado aprovado
- Recibos de verificação
- 1
- Chaves de assinatura que o compilaram
- 1
Ambiente declarado
go 1.26 linux 24 · ubuntu · glibc 2.39 x64 go 1.26 go go 1
Ambientes das execuções de verificação
| Ambiente | Contrato | Etapas | Execução |
|---|---|---|---|
| go 1.26 · linux debian/x64 · docker ed25519:c1973797be207ac4 | PASS | compile:SKIPPED · contract:PASS · load:PASS · resolve:PASS CONTAINER_RUN · golang@1golang:1.26@sha256:e30143be198a… |
2026-10-09 |
Caso
HOW- Objetivo
- verify golang.org/x/mod/module.ModuleError in pkg:golang/golang.org/x/mod@v0.39.0
- Pacotes
- Símbolos
-
- golang.org/x/mod/module.ModuleError
- Ambiente
- go 1.26.6
- Criado
- 2026-10-09T20:37:37Z
Contrato
- module.VersionError returns *ModuleError containing Path, Version, and wrapped Err
- module.Check returns *ModuleError when version does not match module path major
- module.ModuleError Error() formats error with Path and Version when Version is present
- module.ModuleError Error() formats error with module prefix when Version is empty
- module.ModuleError Unwrap() returns the underlying wrapped error
Arquivos
- PROMPT.md
- csx.json
- go.mod
- go.sum
- main.go
- spec.json
- test/contract.go
Código-fonte
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 golang.org/x/mod/module.ModuleError in pkg:golang/golang.org/x/mod@v0.39.0
Kind: HOW
Use EXACTLY these public packages and versions:
- pkg:golang/golang.org/x/mod@v0.39.0
Demonstrate these symbols/APIs:
- golang.org/x/mod/module.ModuleError
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:eccf83bda0641df0ae0378aa61606b519ceec9ae08a93e979682e0b80effd9ad","contract":["module.VersionError returns *ModuleError containing Path, Version, and wrapped Err","module.Check returns *ModuleError when version does not match module path major","module.ModuleError Error() formats error with Path and Version when Version is present","module.ModuleError Error() formats error with module prefix when Version is empty","module.ModuleError Unwrap() returns the underlying wrapped error"],"goal":"verify golang.org/x/mod/module.ModuleError in pkg:golang/golang.org/x/mod@v0.39.0","kind":"HOW","packages":["pkg:golang/golang.org/x/mod@v0.39.0"],"schemaVersion":1,"symbols":["golang.org/x/mod/module.ModuleError"]},"contractCommand":["go","run","./test"],"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/mod@v0.39.0"],"schemaVersion":1,"subject":"pkg:golang/golang.org/x/mod@v0.39.0","symbols":["golang.org/x/mod/module.ModuleError"],"verifierAdapter":"golang@1"}
module example.com/sample
go 1.25.0
require golang.org/x/mod v0.39.0
golang.org/x/mod v0.39.0 h1:UF5zwQdCRRUpHfyPwr7d4UrGiVeldIsogtzWVnczL74=
golang.org/x/mod v0.39.0/go.mod h1:bvIbwjQ0HUFFf5AKukeeYQG4ZBUG9yxQbR9aEweIwYY=
package main
import (
"errors"
"fmt"
"golang.org/x/mod/module"
)
func main() {
v := module.Version{Path: "example.com/mod", Version: "v1.0.0"}
err := module.VersionError(v, errors.New("example failure"))
if err != nil {
var modErr *module.ModuleError
if errors.As(err, &modErr) {
fmt.Printf("Module error: %s@%s: %v\n", modErr.Path, modErr.Version, modErr.Err)
fmt.Printf("Formatted message: %s\n", modErr.Error())
return
}
fmt.Printf("Unexpected error: %v\n", err)
return
}
fmt.Println("No module error.")
}
{
"schemaVersion": 1,
"goal": "verify golang.org/x/mod/module.ModuleError in pkg:golang/golang.org/x/mod@v0.39.0",
"kind": "HOW",
"packages": [
"pkg:golang/golang.org/x/mod@v0.39.0"
],
"symbols": [
"golang.org/x/mod/module.ModuleError"
]
}
package main
import (
"errors"
"fmt"
"os"
"strings"
"golang.org/x/mod/module"
)
func main() {
// 1. module.VersionError returns *ModuleError containing Path, Version, and wrapped Err
{
v := module.Version{
Path: "example.com/foo/bar",
Version: "v1.2.3",
}
cause := errors.New("resolution failed")
err := module.VersionError(v, cause)
if err == nil {
fmt.Fprintf(os.Stderr, "assertion 1 failed: expected error from VersionError\n")
os.Exit(1)
}
var me *module.ModuleError
if !errors.As(err, &me) {
fmt.Fprintf(os.Stderr, "assertion 1 failed: expected *module.ModuleError, got %T\n", err)
os.Exit(1)
}
if me.Path != "example.com/foo/bar" {
fmt.Fprintf(os.Stderr, "assertion 1 failed: expected Path 'example.com/foo/bar', got %q\n", me.Path)
os.Exit(1)
}
if me.Version != "v1.2.3" {
fmt.Fprintf(os.Stderr, "assertion 1 failed: expected Version 'v1.2.3', got %q\n", me.Version)
os.Exit(1)
}
if me.Err != cause {
fmt.Fprintf(os.Stderr, "assertion 1 failed: expected wrapped Err to match cause\n")
os.Exit(1)
}
}
// 2. module.Check returns *ModuleError when version does not match module path major
{
err := module.Check("example.com/foo/v2", "v1.0.0")
if err == nil {
fmt.Fprintf(os.Stderr, "assertion 2 failed: expected error from Check for version mismatch\n")
os.Exit(1)
}
var me *module.ModuleError
if !errors.As(err, &me) {
fmt.Fprintf(os.Stderr, "assertion 2 failed: expected *module.ModuleError, got %T\n", err)
os.Exit(1)
}
if me.Path != "example.com/foo/v2" {
fmt.Fprintf(os.Stderr, "assertion 2 failed: expected Path 'example.com/foo/v2', got %q\n", me.Path)
os.Exit(1)
}
if me.Err == nil {
fmt.Fprintf(os.Stderr, "assertion 2 failed: expected non-nil Err\n")
os.Exit(1)
}
}
// 3. module.ModuleError Error() formats error with Path and Version when Version is present
{
me := &module.ModuleError{
Path: "example.com/pkg",
Version: "v2.1.0",
Err: errors.New("checksum mismatch"),
}
msg := me.Error()
if !strings.Contains(msg, "example.com/pkg@v2.1.0") || !strings.Contains(msg, "checksum mismatch") {
fmt.Fprintf(os.Stderr, "assertion 3 failed: unexpected Error() output: %q\n", msg)
os.Exit(1)
}
}
// 4. module.ModuleError Error() formats error with module prefix when Version is empty
{
me := &module.ModuleError{
Path: "example.com/pkg",
Version: "",
Err: errors.New("invalid path"),
}
msg := me.Error()
if !strings.Contains(msg, "module example.com/pkg") || !strings.Contains(msg, "invalid path") {
fmt.Fprintf(os.Stderr, "assertion 4 failed: unexpected Error() output: %q\n", msg)
os.Exit(1)
}
}
// 5. module.ModuleError Unwrap() returns the underlying wrapped error
{
cause := errors.New("root cause error")
me := &module.ModuleError{
Path: "example.com/target",
Version: "v1.0.0",
Err: cause,
}
if me.Unwrap() != cause {
fmt.Fprintf(os.Stderr, "assertion 5 failed: Unwrap() did not return cause\n")
os.Exit(1)
}
if !errors.Is(me, cause) {
fmt.Fprintf(os.Stderr, "assertion 5 failed: errors.Is did not match cause\n")
os.Exit(1)
}
}
fmt.Println("All contract assertions passed.")
}
Seeder de origem
anônimo