Sample
gopkg.in/errgo.v2 v2.1.0
Verified sample for golang gopkg.in/errgo.v2 v2.1.0. The contract ran on go 1.26 · linux debian/x64 · docker and passed: errors.New creates an error with…
sha256:7369d8eb10c8410755476caf73ff74c71a4a78dc8704b22313f0536fa69354ae
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
linux 24 · ubuntu · glibc 2.39 x64 go
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-09-15 |
Case
HOW- Goal
- verify pkg:golang/gopkg.in/errgo.v2@v2.1.0
- Packages
- Created
- 2026-09-15T21:15:57Z
Contract
- errors.New creates an error with given message
- errors.Wrap wraps an error and preserves error message
- errors.Because attaches a specific cause and contextual message
- errors.Cause returns the root cause of an error wrapped with Because
- errors.Details formats caller stack details for wrapped errors
- fmt/errors.Newf creates formatted errors
- fmt/errors.Becausef attaches cause with formatted message
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 pkg:golang/gopkg.in/errgo.v2@v2.1.0
Kind: HOW
Use EXACTLY these public packages and versions:
- pkg:golang/gopkg.in/errgo.v2@v2.1.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.
{"case":{"caseId":"case:sha256:b943174e9a48065e7fd65b4376babde3ffa4c2cc0b442d3e90b3480938230e47","contract":["errors.New creates an error with given message","errors.Wrap wraps an error and preserves error message","errors.Because attaches a specific cause and contextual message","errors.Cause returns the root cause of an error wrapped with Because","errors.Details formats caller stack details for wrapped errors","fmt/errors.Newf creates formatted errors","fmt/errors.Becausef attaches cause with formatted message"],"goal":"verify pkg:golang/gopkg.in/errgo.v2@v2.1.0","kind":"HOW","packages":["pkg:golang/gopkg.in/errgo.v2@v2.1.0"],"schemaVersion":1},"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/gopkg.in/errgo.v2@v2.1.0"],"schemaVersion":1,"subject":"pkg:golang/gopkg.in/errgo.v2@v2.1.0","verifierAdapter":"golang@1"}
module example.com/sample
go 1.22
require gopkg.in/errgo.v2 v2.1.0
github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo=
github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ=
github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI=
gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
gopkg.in/errgo.v2 v2.1.0 h1:0vLT13EuvQ0hNvakwLuFZ/jYrLp5F3kcWHXdRggjCE8=
gopkg.in/errgo.v2 v2.1.0/go.mod h1:hNsd1EY+bozCKY1Ytp96fpM3vjJbqLJn88ws8XvfDNI=
package main
import (
"fmt"
"gopkg.in/errgo.v2/errors"
fmtErrors "gopkg.in/errgo.v2/fmt/errors"
)
func main() {
// 1. Create a base error
baseErr := errors.New("underlying database connection refused")
fmt.Println("Base error:", baseErr)
// 2. Wrap the error to capture caller location while hiding cause
wrappedErr := errors.Wrap(baseErr)
fmt.Println("Wrapped error:", wrappedErr)
// 3. Attach a root cause with contextual explanation
rootCause := errors.New("connection timeout")
becauseErr := errors.Because(baseErr, rootCause, "failed query execution")
fmt.Println("Because error:", becauseErr)
fmt.Println("Extracted cause:", errors.Cause(becauseErr))
// 4. Formatted errors with fmt/errors
formattedErr := fmtErrors.Newf("request failed with status %d", 503)
fmt.Println("Formatted error:", formattedErr)
formattedWithCause := fmtErrors.Becausef(baseErr, rootCause, "service %s unavailable", "order-api")
fmt.Println("Formatted with cause:", formattedWithCause)
fmt.Println("Extracted cause:", fmtErrors.Cause(formattedWithCause))
}
{
"schemaVersion": 1,
"goal": "verify pkg:golang/gopkg.in/errgo.v2@v2.1.0",
"kind": "HOW",
"packages": [
"pkg:golang/gopkg.in/errgo.v2@v2.1.0"
]
}
package main
import (
"fmt"
"os"
"strings"
"gopkg.in/errgo.v2/errors"
fmtErrors "gopkg.in/errgo.v2/fmt/errors"
)
func main() {
if err := runContractTests(); err != nil {
fmt.Fprintf(os.Stderr, "Contract test failed: %v\n", err)
os.Exit(1)
}
fmt.Println("All errgo.v2 contract assertions passed.")
}
func runContractTests() error {
// Assertion 1: errors.New creates an error with given message
err1 := errors.New("operation failed")
if err1 == nil || err1.Error() != "operation failed" {
return fmt.Errorf("expected 'operation failed', got %v", err1)
}
// Assertion 2: errors.Wrap wraps an error and preserves error message
errWrapped := errors.Wrap(err1)
if errWrapped == nil || errWrapped.Error() != "operation failed" {
return fmt.Errorf("expected wrapped 'operation failed', got %v", errWrapped)
}
// Assertion 3: errors.Because attaches a specific cause and contextual message
rootCause := errors.New("disk full")
errBecause := errors.Because(err1, rootCause, "failed to save")
if errBecause == nil || errBecause.Error() != "failed to save: operation failed" {
return fmt.Errorf("expected 'failed to save: operation failed', got %v", errBecause)
}
// Assertion 4: errors.Cause returns the root cause of an error wrapped with Because
extractedCause := errors.Cause(errBecause)
if extractedCause != rootCause {
return fmt.Errorf("expected cause %v, got %v", rootCause, extractedCause)
}
// Assertion 5: errors.Details formats caller stack details for wrapped errors
details := errors.Details(errBecause)
if !strings.Contains(details, "failed to save") || !strings.Contains(details, "operation failed") {
return fmt.Errorf("expected details to contain stack info, got: %s", details)
}
// Assertion 6: fmt/errors.Newf creates formatted errors
errFmt := fmtErrors.Newf("code %d: %s", 404, "not found")
if errFmt == nil || errFmt.Error() != "code 404: not found" {
return fmt.Errorf("expected 'code 404: not found', got %v", errFmt)
}
// Assertion 7: fmt/errors.Becausef attaches cause with formatted message
errFmtBecause := fmtErrors.Becausef(err1, rootCause, "request %d failed", 123)
if errFmtBecause == nil || errFmtBecause.Error() != "request 123 failed: operation failed" {
return fmt.Errorf("expected 'request 123 failed: operation failed', got %v", errFmtBecause)
}
if fmtErrors.Cause(errFmtBecause) != rootCause {
return fmt.Errorf("expected cause %v, got %v", rootCause, fmtErrors.Cause(errFmtBecause))
}
return nil
}
Origin Seeder
anonymous