Sample
golang.org/x/mod v0.39.0: module.ModuleError
Verified sample for golang golang.org/x/mod v0.39.0: module.ModuleError. The contract ran on go 1.26 · linux debian/x64 · docker and passed.
sha256:6af6fe095cd7368c07dd0e92b29536b775da0e2e8fb1b00c0816b61913208ca9
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:SKIPPED · contract:PASS · load:PASS · resolve:PASS CONTAINER_RUN · golang@1golang:1.26@sha256:e30143be198a… |
2026-10-09 |
Case
HOW- Goal
- verify golang.org/x/mod/module.ModuleError in pkg:golang/golang.org/x/mod@v0.39.0
- Packages
- Symbols
-
- golang.org/x/mod/module.ModuleError
- Environment
- go 1.26.6
- Created
- 2026-10-09T20:37:37Z
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
Files
- PROMPT.md
- csx.json
- go.mod
- go.sum
- main.go
- 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 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.")
}
Origin Seeder
anonymous