CodeSampleX

Sample

github.com/spf13/cast v1.7.0: ToBool

Verified sample for golang github.com/spf13/cast v1.7.0: ToBool. The contract ran on go 1.26 · linux alpine/x64 · docker and passed.

sha256:8c263d99c6d11c29d5a163b2e14d4aaf23aaf5c7a4bb794f663b76cbb5ab882a

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 alpine/x64 · docker ed25519:c1973797be207ac4 PASS compile:SKIPPED · contract:PASS · load:PASS · resolve:PASS
CONTAINER_RUN · golang@1
2026-08-21

Case

HOW
Goal
verify github.com/spf13/cast.ToBool in pkg:golang/github.com/spf13/cast@v1.7.0
Packages
Symbols
  • github.com/spf13/cast.ToBool
Created
2026-08-21T00:08:33Z

Contract

  1. cast.ToBool converts truthy and falsy values of various types to boolean
  2. ToBool converts the given value to a boolean using cast.ToBool

Files

  • PROMPT.md
  • bool_sample.go
  • bool_sample_test.go
  • csx.json
  • go.mod
  • go.sum
  • spec.json

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 github.com/spf13/cast.ToBool in pkg:golang/github.com/spf13/cast@v1.7.0
Kind: HOW

Use EXACTLY these public packages and versions:
  - pkg:golang/github.com/spf13/cast@v1.7.0
Demonstrate these symbols/APIs:
  - github.com/spf13/cast.ToBool

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.
bool_sample.go
package sample

import (
	"github.com/spf13/cast"
)

// ToBool converts the given value to a boolean using cast.ToBool.
func ToBool(val any) bool {
	return cast.ToBool(val)
}
bool_sample_test.go
package sample

import (
	"testing"

	"github.com/spf13/cast"
)

func TestToBoolDirect(t *testing.T) {
	tests := []struct {
		input    any
		expected bool
	}{
		{true, true},
		{false, false},
		{1, true},
		{0, false},
		{"true", true},
		{"TRUE", true},
		{"t", true},
		{"T", true},
		{"1", true},
		{"false", false},
		{"FALSE", false},
		{"f", false},
		{"F", false},
		{"0", false},
		{nil, false},
		{"invalid", false},
	}

	for _, tt := range tests {
		got := cast.ToBool(tt.input)
		if got != tt.expected {
			t.Errorf("cast.ToBool(%v) = %v; want %v", tt.input, got, tt.expected)
		}
	}
}

func TestToBoolHelper(t *testing.T) {
	if !ToBool("true") {
		t.Errorf("ToBool(\"true\") = false; want true")
	}
	if ToBool("false") {
		t.Errorf("ToBool(\"false\") = true; want false")
	}
	if !ToBool(1) {
		t.Errorf("ToBool(1) = false; want true")
	}
	if ToBool(0) {
		t.Errorf("ToBool(0) = true; want false")
	}
}
csx.json
{"case":{"caseId":"case:sha256:61ee9d8e3b55dfe7018e834eab6f2a70ed741ba4032e8240a3e01217836b3d00","contract":["cast.ToBool converts truthy and falsy values of various types to boolean","ToBool converts the given value to a boolean using cast.ToBool"],"goal":"verify github.com/spf13/cast.ToBool in pkg:golang/github.com/spf13/cast@v1.7.0","kind":"HOW","packages":["pkg:golang/github.com/spf13/cast@v1.7.0"],"schemaVersion":1,"symbols":["github.com/spf13/cast.ToBool"]},"contractCommand":["go","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/github.com/spf13/cast@v1.7.0"],"schemaVersion":1,"subject":"pkg:golang/github.com/spf13/cast@v1.7.0","symbols":["github.com/spf13/cast.ToBool"],"verifierAdapter":"golang@1"}
go.mod
module sample

go 1.26.6

require github.com/spf13/cast v1.7.0
go.sum
github.com/frankban/quicktest v1.14.6 h1:7Xjx+VpznH+oBnejlPUj8oUpdxnVs4f8XU8WnHkI4W8=
github.com/frankban/quicktest v1.14.6/go.mod h1:4ptaffx2x8+WTWXmUCuVU6aPUX1/Mz7zb5vbUoiM6w0=
github.com/google/go-cmp v0.5.9 h1:O2Tfq5qg4qc4AmwVlvv0oLiVAGB7enBSJ2x2DqQFi38=
github.com/google/go-cmp v0.5.9/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY=
github.com/kr/pretty v0.3.1 h1:flRD4NNwYAUpkphVc1HcthR4KEIFJ65n8Mw5qdRn3LE=
github.com/kr/pretty v0.3.1/go.mod h1:hoEshYVHaxMs3cyo3Yncou5ZscifuDolrwPKZanG3xk=
github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY=
github.com/kr/text v0.2.0/go.mod h1:eLer722TekiGuMkidMxC/pM04lWEeraHUUmBw8l2grE=
github.com/rogpeppe/go-internal v1.9.0 h1:73kH8U+JUqXU8lRuOHeVHaa/SZPifC7BkcraZVejAe8=
github.com/rogpeppe/go-internal v1.9.0/go.mod h1:WtVeX8xhTBvf0smdhujwtBcq4Qrzq/fJaraNFVN+nFs=
github.com/spf13/cast v1.7.0 h1:ntdiHjuueXFgm5nzDRdOS4yfT43P5Fnud6DH50rz/7w=
github.com/spf13/cast v1.7.0/go.mod h1:ancEpBxwJDODSW/UG4rDrAqiKolqNNh2DX3mk86cAdo=
spec.json
{
  "schemaVersion": 1,
  "goal": "verify github.com/spf13/cast.ToBool in pkg:golang/github.com/spf13/cast@v1.7.0",
  "kind": "HOW",
  "packages": [
    "pkg:golang/github.com/spf13/cast@v1.7.0"
  ],
  "symbols": [
    "github.com/spf13/cast.ToBool"
  ]
}

Origin Seeder

anonymous