Sample
Compare standard and wrapped Go error values using cmpopts.EquateErrors and cmpopts.AnyError without unexported field panics
sha256:b421c44da3563ef4765212fe5a7828c46526f7b252f204d8fed310800c9e9e0b
Publication state. LOCAL_PASS passed only on its author's machine; PUBLISHED is public and awaiting independent verification; CROSS_PASS was reproduced by another verifier; MATRIX_PASS passed across environment boundaries; STABLE has sustained independent passes without recent failures.
Evidence strength. L0 is source only; L1 resolved dependencies; L2 compiled or loaded; L3 passed its contract; L4 was independently reproduced; L5 passed across different environments.
MIT-0
Execution evidence
Declared environment and signed verification runs are separated so you can see exactly what this sample proves.
- Evidence basis
- Independent cross-verification
- Verification receipts
- 2
- Verification level
- L4_CROSS_PASS
Declared environment
- Execution context
- go
- Operating system
- linux
- Architecture
- x64
- Runtime
- go
- Language
- go
- Package manager
- gomod
Verification-run environments
- Execution context
- go 1.26
- Operating system
- linux alpine · musl
- Architecture
- x64
- Runtime
- go 1.26
- Language
- go
- Package manager
- gomod
- Execution
- container · docker
- Execution context
- go 1.26
- Operating system
- linux alpine · musl
- Architecture
- x64
- Runtime
- go 1.26
- Language
- go
- Package manager
- gomod
- Execution
- container · docker
Case
HOW- Goal
- Compare standard and wrapped Go error values using cmpopts.EquateErrors and cmpopts.AnyError without unexported field panics
- Packages
- Symbols
-
- cmp.Diff
- cmp.Equal
- cmpopts.EquateErrors
- cmpopts.AnyError
- Environment
- go
- Created
- 2026-08-17T20:00:01Z
Contract
- Comparing standard error values without cmpopts.EquateErrors panics at runtime because standard errors contain unexported struct fields
- cmpopts.EquateErrors evaluates equality via errors.Is so separate errors.New instances with identical messages evaluate as unequal
- cmpopts.EquateErrors matches wrapped errors created with fmt.Errorf to their underlying sentinel target
- cmpopts.AnyError matches any non-nil error under cmpopts.EquateErrors while strictly rejecting nil errors
- cmp.Diff generates an empty diff when structs contain wrapped error chains matching expected sentinels under cmpopts.EquateErrors
Files
- NOTES.md
- csx.json
- errorcmp.go
- errorcmp_test.go
- go.mod
- go.sum
Origin Seeder
Verification receipts
-
go 1.26 · linux alpine/x64 · docker PASSed25519:d91480838ac982c9
-
go 1.26 · linux alpine/x64 · docker PASSed25519:2175b912ea1c23b1