CodeSampleX

Sample

go.uber.org/multierr v1.11.0: Append

Verified sample for golang go.uber.org/multierr v1.11.0: Append. The contract ran on go 1.26 · linux debian/x64 · docker and passed.

sha256:459dbc18f67ce29e475591937ed290dfc3a088de7b4f574345bfb8e53fa19495

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 amd64 go 1.26 go 1.26 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-09-05

Case

HOW
Goal
verify go.uber.org/multierr.Append in pkg:golang/go.uber.org/multierr@v1.11.0
Packages
Symbols
  • go.uber.org/multierr.Append
Environment
go 1.26.6
Created
2026-09-05T22:20:05Z

Contract

  1. multierr.Append with nil errors returns nil or the non-nil error unmodified
  2. multierr.Append combines two non-nil errors into a single aggregated error
  3. multierr.Append flattens multi-errors into a single flat error chain
  4. multierr.Errors extracts the flat underlying error slice from an aggregated error
  5. multierr.Append preserves order and formatted Error string concatenates messages with semicolon

Files

  • PROMPT.md
  • csx.json
  • go.mod
  • go.sum
  • sample.go
  • spec.json
  • test/contract_test.go

Download the source artifact (tar.gz)

Source

PROMPT.md
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 go.uber.org/multierr.Append in pkg:golang/go.uber.org/multierr@v1.11.0
Kind: HOW

Use EXACTLY these public packages and versions:
  - pkg:golang/go.uber.org/multierr@v1.11.0
Demonstrate these symbols/APIs:
  - go.uber.org/multierr.Append

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.
csx.json
{"case":{"caseId":"case:sha256:0bcff5381040b9c90e3c4eea253f878429a7c7603ba67a1b6e5e91116967bf60","contract":["multierr.Append with nil errors returns nil or the non-nil error unmodified","multierr.Append combines two non-nil errors into a single aggregated error","multierr.Append flattens multi-errors into a single flat error chain","multierr.Errors extracts the flat underlying error slice from an aggregated error","multierr.Append preserves order and formatted Error string concatenates messages with semicolon"],"goal":"verify go.uber.org/multierr.Append in pkg:golang/go.uber.org/multierr@v1.11.0","kind":"HOW","packages":["pkg:golang/go.uber.org/multierr@v1.11.0"],"schemaVersion":1,"symbols":["go.uber.org/multierr.Append"]},"contractCommand":["go","test","./..."],"environment":{"arch":"amd64","distro":"ubuntu","ecosystem":"golang","language":"go","languageVersion":"1.26.6","libc":"glibc","libcVersion":"2.39","moduleSystem":"go.mod","os":"linux","osVersionBucket":"24","packageManager":"go","packageManagerVersion":"1.26.6","runtime":"go","runtimeVersion":"1.26.6","schemaVersion":1},"license":"MIT-0","packages":["pkg:golang/go.uber.org/multierr@v1.11.0"],"schemaVersion":1,"subject":"pkg:golang/go.uber.org/multierr@v1.11.0","symbols":["go.uber.org/multierr.Append"],"verifierAdapter":"golang@1"}
go.mod
module sample

go 1.26.6

require go.uber.org/multierr v1.11.0
go.sum
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
github.com/stretchr/testify v1.7.0 h1:nwc3DEeHmmLAfoZucVR881uASk0Mfjw8xYJ99tb5CcY=
github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
go.uber.org/multierr v1.11.0 h1:blXXJkSxSSfBVBlC76pxqeO+LN3aDfLQo+309xJstO0=
go.uber.org/multierr v1.11.0/go.mod h1:20+QtiLqy0Nd6FdQB9TLXag12DsQkrbs3htMFfDN80Y=
gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA=
gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
sample.go
package sample

import (
	"go.uber.org/multierr"
)

// Aggregate executes operations sequentially and accumulates any errors using multierr.Append.
func Aggregate(ops ...func() error) error {
	var combined error
	for _, op := range ops {
		if op != nil {
			combined = multierr.Append(combined, op())
		}
	}
	return combined
}

// CombineTwo combines two errors into a single error via multierr.Append.
func CombineTwo(left, right error) error {
	return multierr.Append(left, right)
}
spec.json
{
  "schemaVersion": 1,
  "goal": "verify go.uber.org/multierr.Append in pkg:golang/go.uber.org/multierr@v1.11.0",
  "kind": "HOW",
  "packages": [
    "pkg:golang/go.uber.org/multierr@v1.11.0"
  ],
  "symbols": [
    "go.uber.org/multierr.Append"
  ]
}
test/contract_test.go
package test

import (
	"errors"
	"testing"

	"sample"

	"go.uber.org/multierr"
)

func TestMultierrAppendNilHandlingContract(t *testing.T) {
	// 1. multierr.Append with nil errors returns nil or the non-nil error unmodified
	if err := multierr.Append(nil, nil); err != nil {
		t.Fatalf("expected Append(nil, nil) to be nil, got: %v", err)
	}

	errA := errors.New("errA")
	if got := multierr.Append(errA, nil); got != errA {
		t.Fatalf("expected Append(errA, nil) to return errA directly, got: %v", got)
	}

	errB := errors.New("errB")
	if got := multierr.Append(nil, errB); got != errB {
		t.Fatalf("expected Append(nil, errB) to return errB directly, got: %v", got)
	}
}

func TestMultierrAppendCombineAndFlattenContract(t *testing.T) {
	err1 := errors.New("first error")
	err2 := errors.New("second error")
	err3 := errors.New("third error")

	// 2. multierr.Append combines two non-nil errors into a single aggregated error
	combined := multierr.Append(err1, err2)
	if combined == nil {
		t.Fatal("expected combined error to be non-nil")
	}
	expectedMsg := "first error; second error"
	if combined.Error() != expectedMsg {
		t.Fatalf("expected %q, got %q", expectedMsg, combined.Error())
	}

	// 3. multierr.Append flattens multi-errors into a single flat error chain
	nested := multierr.Append(combined, err3)
	errs := multierr.Errors(nested)
	if len(errs) != 3 {
		t.Fatalf("expected 3 flattened errors, got %d", len(errs))
	}

	// Also verify right-hand flattening
	nestedRight := multierr.Append(err1, multierr.Append(err2, err3))
	errsRight := multierr.Errors(nestedRight)
	if len(errsRight) != 3 {
		t.Fatalf("expected 3 flattened errors on right append, got %d", len(errsRight))
	}

	// 4. multierr.Errors extracts the flat underlying error slice from an aggregated error
	nilSlice := multierr.Errors(nil)
	if len(nilSlice) != 0 {
		t.Fatalf("expected empty slice for nil error, got %d", len(nilSlice))
	}

	singleSlice := multierr.Errors(err1)
	if len(singleSlice) != 1 || singleSlice[0] != err1 {
		t.Fatalf("expected single element slice with err1, got %v", singleSlice)
	}

	if errs[0] != err1 || errs[1] != err2 || errs[2] != err3 {
		t.Fatalf("extracted slice did not match original error sequence: %v", errs)
	}
}

func TestMultierrAppendOrderingAndFormattingContract(t *testing.T) {
	// 5. multierr.Append preserves order and formatted Error string concatenates messages with semicolon
	errStep1 := errors.New("initialization failed")
	errStep2 := errors.New("network timeout")
	errStep3 := errors.New("cleanup failed")

	res := sample.Aggregate(
		func() error { return errStep1 },
		func() error { return nil },
		func() error { return errStep2 },
		func() error { return errStep3 },
	)

	if res == nil {
		t.Fatal("expected aggregated error to be non-nil")
	}

	expectedStr := "initialization failed; network timeout; cleanup failed"
	if res.Error() != expectedStr {
		t.Fatalf("expected error string %q, got %q", expectedStr, res.Error())
	}

	errList := multierr.Errors(res)
	if len(errList) != 3 {
		t.Fatalf("expected 3 errors in list, got %d", len(errList))
	}
	if errList[0] != errStep1 || errList[1] != errStep2 || errList[2] != errStep3 {
		t.Fatalf("errors not in preserved order: %v", errList)
	}

	// Test CombineTwo wrapper
	c2 := sample.CombineTwo(errStep1, errStep2)
	if c2.Error() != "initialization failed; network timeout" {
		t.Fatalf("CombineTwo failed: %v", c2)
	}
}

Origin Seeder

anonymous