Sample
golang.org/x/text v0.23.0: collate.Collator.Compare, collate.New, currency.ParseISO
Verified sample for golang golang.org/x/text v0.23.0: collate.Collator.Compare, collate.New, currency.ParseISO. The contract ran on go 1.26 · linux…
sha256:b995f5cb6966c6f535504f27ebe60d412d56a82f105fae77a54e7e761236c8d5
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@1golang:1.26-alpine@sha256:28d89ee9cc0f… |
2026-08-27 |
Case
HOW- Goal
- verify pkg:golang/golang.org/x/text@v0.23.0
- Packages
- Symbols
-
- collate.Collator.Compare
- collate.New
- currency.ParseISO
- message.NewPrinter
- search.New
- Created
- 2026-08-27T15:38:32Z
Contract
- collate.New creates locale-sensitive collator comparing strings according to language collation rules
- collate.Collator.Compare compares byte slices returning negative, zero, or positive integer based on lexical ordering
- currency.ParseISO parses standard 3-letter currency codes and produces currency amounts
- message.NewPrinter formats localized numbers and strings according to language locale conventions
- search.New and Pattern.IndexString perform locale-aware substring searches within strings
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/golang.org/x/text@v0.23.0
Kind: HOW
Use EXACTLY these public packages and versions:
- pkg:golang/golang.org/x/text@v0.23.0
Demonstrate these symbols/APIs:
- collate.Collator.Compare
- collate.New
- currency.ParseISO
- message.NewPrinter
- search.New
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:3012f4c2eadd0979c12293b8395306045c01bfd96a268124c6abe87c9f77fb1d","contract":["collate.New creates locale-sensitive collator comparing strings according to language collation rules","collate.Collator.Compare compares byte slices returning negative, zero, or positive integer based on lexical ordering","currency.ParseISO parses standard 3-letter currency codes and produces currency amounts","message.NewPrinter formats localized numbers and strings according to language locale conventions","search.New and Pattern.IndexString perform locale-aware substring searches within strings"],"goal":"verify pkg:golang/golang.org/x/text@v0.23.0","kind":"HOW","packages":["pkg:golang/golang.org/x/text@v0.23.0"],"schemaVersion":1,"symbols":["collate.Collator.Compare","collate.New","currency.ParseISO","message.NewPrinter","search.New"]},"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/golang.org/x/text@v0.23.0"],"schemaVersion":1,"subject":"pkg:golang/golang.org/x/text@v0.23.0","symbols":["collate.Collator.Compare","collate.New","currency.ParseISO","message.NewPrinter","search.New"],"verifierAdapter":"golang@1"}
module example.com/sample
go 1.26.6
require golang.org/x/text v0.23.0
golang.org/x/text v0.23.0 h1:D71I7dUrlY+VX0gQShAThNGHFxZ13dGLBHQLVl1mJlY=
golang.org/x/text v0.23.0/go.mod h1:/BLNzu4aZCJ1+kcD0DNRotWKage4q2rGVAg4o22unh4=
package main
import (
"fmt"
"os"
"golang.org/x/text/collate"
"golang.org/x/text/currency"
"golang.org/x/text/language"
"golang.org/x/text/message"
"golang.org/x/text/search"
)
// CollateStrings compares two strings using a language-specific collator.
func CollateStrings(tag language.Tag, a, b string) int {
c := collate.New(tag)
return c.CompareString(a, b)
}
// CollateBytes compares two byte slices using an English collator.
func CollateBytes(a, b []byte) int {
c := collate.New(language.English)
return c.Compare(a, b)
}
// FormatCurrencyAmount parses an ISO currency code and formats an amount.
func FormatCurrencyAmount(isoCode string, amount float64) (string, error) {
unit, err := currency.ParseISO(isoCode)
if err != nil {
return "", err
}
amt := unit.Amount(amount)
return fmt.Sprintf("%v", amt), nil
}
// FormatLocalizedNumber formats a floating-point number for the specified locale.
func FormatLocalizedNumber(tag language.Tag, number float64) string {
p := message.NewPrinter(tag)
return p.Sprintf("%.2f", number)
}
// FindSubstring searches for a query substring within a target text ignoring case.
func FindSubstring(tag language.Tag, target, query string) (int, int) {
matcher := search.New(tag, search.IgnoreCase)
pattern := matcher.CompileString(query)
return pattern.IndexString(target)
}
func main() {
// 1. Collation
deRes := CollateStrings(language.German, "ö", "z")
seRes := CollateStrings(language.Swedish, "ö", "z")
fmt.Printf("German collation 'ö' vs 'z': %d\n", deRes)
fmt.Printf("Swedish collation 'ö' vs 'z': %d\n", seRes)
// 2. Byte comparison
byteCmp := CollateBytes([]byte("apple"), []byte("banana"))
fmt.Printf("Byte collation 'apple' vs 'banana': %d\n", byteCmp)
// 3. Currency parsing
usdFormatted, err := FormatCurrencyAmount("USD", 1234.56)
if err != nil {
fmt.Fprintf(os.Stderr, "Error formatting currency: %v\n", err)
os.Exit(1)
}
fmt.Printf("Currency: %s\n", usdFormatted)
// 4. Localized message printing
enNum := FormatLocalizedNumber(language.AmericanEnglish, 1234567.89)
deNum := FormatLocalizedNumber(language.German, 1234567.89)
fmt.Printf("Formatted EN: %s\n", enNum)
fmt.Printf("Formatted DE: %s\n", deNum)
// 5. Search
start, end := FindSubstring(language.English, "Hello World!", "world")
fmt.Printf("Substring match: [%d, %d)\n", start, end)
}
{
"schemaVersion": 1,
"goal": "verify pkg:golang/golang.org/x/text@v0.23.0",
"kind": "HOW",
"packages": [
"pkg:golang/golang.org/x/text@v0.23.0"
],
"symbols": [
"collate.Collator.Compare",
"collate.New",
"currency.ParseISO",
"message.NewPrinter",
"search.New"
]
}
package main
import (
"fmt"
"os"
"golang.org/x/text/collate"
"golang.org/x/text/currency"
"golang.org/x/text/language"
"golang.org/x/text/message"
"golang.org/x/text/search"
)
func main() {
// Assertion 1: collate.New creates locale-sensitive collator comparing strings according to language collation rules
cGerman := collate.New(language.German)
cSwedish := collate.New(language.Swedish)
if cGerman.CompareString("ö", "z") >= 0 {
fmt.Fprintf(os.Stderr, "FAIL: German collation expected 'ö' < 'z'\n")
os.Exit(1)
}
if cSwedish.CompareString("ö", "z") <= 0 {
fmt.Fprintf(os.Stderr, "FAIL: Swedish collation expected 'ö' > 'z'\n")
os.Exit(1)
}
// Assertion 2: collate.Collator.Compare compares byte slices returning negative, zero, or positive integer based on lexical ordering
cEn := collate.New(language.English)
if cmp := cEn.Compare([]byte("apple"), []byte("banana")); cmp >= 0 {
fmt.Fprintf(os.Stderr, "FAIL: expected 'apple' < 'banana', got %d\n", cmp)
os.Exit(1)
}
if cmp := cEn.Compare([]byte("same"), []byte("same")); cmp != 0 {
fmt.Fprintf(os.Stderr, "FAIL: expected equal byte comparison 0, got %d\n", cmp)
os.Exit(1)
}
if cmp := cEn.Compare([]byte("zoo"), []byte("ant")); cmp <= 0 {
fmt.Fprintf(os.Stderr, "FAIL: expected 'zoo' > 'ant', got %d\n", cmp)
os.Exit(1)
}
// Assertion 3: currency.ParseISO parses standard 3-letter currency codes and produces currency amounts
usd, err := currency.ParseISO("USD")
if err != nil || usd.String() != "USD" {
fmt.Fprintf(os.Stderr, "FAIL: currency.ParseISO(\"USD\") failed: %v\n", err)
os.Exit(1)
}
eur, err := currency.ParseISO("EUR")
if err != nil || eur.String() != "EUR" {
fmt.Fprintf(os.Stderr, "FAIL: currency.ParseISO(\"EUR\") failed: %v\n", err)
os.Exit(1)
}
amt := usd.Amount(100.50)
if amt.Currency() != usd {
fmt.Fprintf(os.Stderr, "FAIL: currency amount mismatch: %v\n", amt)
os.Exit(1)
}
// Assertion 4: message.NewPrinter formats localized numbers and strings according to language locale conventions
pEn := message.NewPrinter(language.AmericanEnglish)
formattedEn := pEn.Sprintf("%.2f", 1234567.89)
if formattedEn != "1,234,567.89" {
fmt.Fprintf(os.Stderr, "FAIL: English formatting mismatch: got %q, expected %q\n", formattedEn, "1,234,567.89")
os.Exit(1)
}
pDe := message.NewPrinter(language.German)
formattedDe := pDe.Sprintf("%.2f", 1234567.89)
if formattedDe != "1.234.567,89" {
fmt.Fprintf(os.Stderr, "FAIL: German formatting mismatch: got %q, expected %q\n", formattedDe, "1.234.567,89")
os.Exit(1)
}
// Assertion 5: search.New and Pattern.IndexString perform locale-aware substring searches within strings
m := search.New(language.English, search.IgnoreCase)
pattern := m.CompileString("world")
start, end := pattern.IndexString("Hello World!")
if start != 6 || end != 11 {
fmt.Fprintf(os.Stderr, "FAIL: search.New pattern index mismatch: got (%d, %d), expected (6, 11)\n", start, end)
os.Exit(1)
}
fmt.Println("PASS: pkg:golang/golang.org/x/text@v0.23.0 contract verified")
}
Origin Seeder
anonymous