CodeSampleX

Exemple

golang.org/x/text v0.16.0: cases.NoLower

Échantillon vérifié pour golang golang.org/x/text v0.16.0: cases.NoLower. Le contrat s'est exécuté sur go 1.26 · linux debian/x64 · docker et a réussi.

sha256:f71b174d0d2d444a497e578bc65651b356ebd5bb27118894afa388fc007db79a

Ce réseau offre une seule chose : un échantillon qui compile. Il l'a exécuté dans un bac à sable et conservé le reçu signé. Il ne note rien et ne garantit rien : si le même code compile chez vous, il ne l'a pas mesuré. Combien de clés de signature distinctes ont déposé un reçu de contrat réussi. Une seule, c'est l'auteur ; plus d'une signifie que quelqu'un d'autre l'a compilé aussi. Une clé est auto-générée sans identité enregistrée derrière, donc on compte des clés, pas des personnes. MIT-0

Preuves d'exécution

L'environnement déclaré et les exécutions signées sont séparés, pour que vous voyiez exactement ce que cet échantillon a exécuté et où.

Base de preuve
Contrat signé réussi
Reçus de vérification
1
Clés de signature qui l’ont compilé
1
Environnement déclaré linux 24 · ubuntu · glibc 2.39 x64 go

Environnements des exécutions de vérification

Environnement Contrat Étapes Exécution
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

Cas

HOW
Objectif
verify golang.org/x/text/cases.NoLower in pkg:golang/golang.org/x/text@v0.16.0
Paquets
Symboles
  • golang.org/x/text/cases.NoLower
Créé
2026-09-15T02:24:10Z

Contrat

  1. Title Caser with NoLower preserves uppercase characters in words
  2. Title Caser without NoLower lowers non-initial uppercase characters
  3. Title Caser with NoLower preserves all-caps acronyms
  4. Title Caser with NoLower capitalizes initial lowercase letters
  5. Title Caser with NoLower transforms byte slices correctly
  6. Title Caser with NoLower respects language-specific casing rules
  7. Title Caser with NoLower handles empty string input
  8. Title Caser with NoLower handles mixed punctuation and whitespace

Fichiers

  • PROMPT.md
  • csx.json
  • go.mod
  • go.sum
  • main.go
  • spec.json
  • test/contract.go

Télécharger l’artefact source (tar.gz)

Code 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 golang.org/x/text/cases.NoLower in pkg:golang/golang.org/x/text@v0.16.0
Kind: HOW

Use EXACTLY these public packages and versions:
  - pkg:golang/golang.org/x/text@v0.16.0
Demonstrate these symbols/APIs:
  - golang.org/x/text/cases.NoLower

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:7e2c24680435d51380b748e3f0f27b1ea32afcceeb91ac1f7735f7e93e6f4246","contract":["Title Caser with NoLower preserves uppercase characters in words","Title Caser without NoLower lowers non-initial uppercase characters","Title Caser with NoLower preserves all-caps acronyms","Title Caser with NoLower capitalizes initial lowercase letters","Title Caser with NoLower transforms byte slices correctly","Title Caser with NoLower respects language-specific casing rules","Title Caser with NoLower handles empty string input","Title Caser with NoLower handles mixed punctuation and whitespace"],"goal":"verify golang.org/x/text/cases.NoLower in pkg:golang/golang.org/x/text@v0.16.0","kind":"HOW","packages":["pkg:golang/golang.org/x/text@v0.16.0"],"schemaVersion":1,"symbols":["golang.org/x/text/cases.NoLower"]},"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.16.0"],"schemaVersion":1,"subject":"pkg:golang/golang.org/x/text@v0.16.0","symbols":["golang.org/x/text/cases.NoLower"],"verifierAdapter":"golang@1"}
go.mod
module example.com/sample

go 1.26.6

require golang.org/x/text v0.16.0
go.sum
golang.org/x/text v0.16.0 h1:a94ExnEXNtEwYLGJSIUxnWoxoRz/ZcCsV63ROupILh4=
golang.org/x/text v0.16.0/go.mod h1:GhwF1Be+LQoKShO3cGOHzqOgRrGaYc9AvblQOmPVHnI=
main.go
package main

import (
	"fmt"

	"golang.org/x/text/cases"
	"golang.org/x/text/language"
)

func main() {
	defaultTitle := cases.Title(language.English)
	noLowerTitle := cases.Title(language.English, cases.NoLower)

	input := "iPhone and iPad running iOS"
	fmt.Println("Default Title:", defaultTitle.String(input))
	fmt.Println("NoLower Title:", noLowerTitle.String(input))
}
spec.json
{
  "schemaVersion": 1,
  "goal": "verify golang.org/x/text/cases.NoLower in pkg:golang/golang.org/x/text@v0.16.0",
  "kind": "HOW",
  "packages": [
    "pkg:golang/golang.org/x/text@v0.16.0"
  ],
  "symbols": [
    "golang.org/x/text/cases.NoLower"
  ]
}
test/contract.go
package main

import (
	"bytes"
	"fmt"
	"os"

	"golang.org/x/text/cases"
	"golang.org/x/text/language"
)

func main() {
	// 1. Title Caser with NoLower preserves uppercase characters in words
	titleNoLower := cases.Title(language.English, cases.NoLower)
	if got := titleNoLower.String("iPhone and iPad"); got != "IPhone And IPad" {
		fmt.Fprintf(os.Stderr, "Assertion 1 failed: expected 'IPhone And IPad', got %q\n", got)
		os.Exit(1)
	}

	// 2. Title Caser without NoLower lowers non-initial uppercase characters
	titleDefault := cases.Title(language.English)
	if got := titleDefault.String("iPhone and iPad"); got != "Iphone And Ipad" {
		fmt.Fprintf(os.Stderr, "Assertion 2 failed: expected 'Iphone And Ipad', got %q\n", got)
		os.Exit(1)
	}

	// 3. Title Caser with NoLower preserves all-caps acronyms
	if got := titleNoLower.String("NASA and ESA"); got != "NASA And ESA" {
		fmt.Fprintf(os.Stderr, "Assertion 3 failed: expected 'NASA And ESA', got %q\n", got)
		os.Exit(1)
	}

	// 4. Title Caser with NoLower capitalizes initial lowercase letters
	if got := titleNoLower.String("hello world"); got != "Hello World" {
		fmt.Fprintf(os.Stderr, "Assertion 4 failed: expected 'Hello World', got %q\n", got)
		os.Exit(1)
	}

	// 5. Title Caser with NoLower transforms byte slices correctly
	inputBytes := []byte("gRPC service")
	if got := titleNoLower.Bytes(inputBytes); !bytes.Equal(got, []byte("GRPC Service")) {
		fmt.Fprintf(os.Stderr, "Assertion 5 failed: expected 'GRPC Service', got %q\n", string(got))
		os.Exit(1)
	}

	// 6. Title Caser with NoLower respects language-specific casing rules
	dutchNoLower := cases.Title(language.Dutch, cases.NoLower)
	if got := dutchNoLower.String("ijsland and IJsselmeer"); got != "IJsland And IJsselmeer" {
		fmt.Fprintf(os.Stderr, "Assertion 6 failed: expected 'IJsland And IJsselmeer', got %q\n", got)
		os.Exit(1)
	}

	// 7. Title Caser with NoLower handles empty string input
	if got := titleNoLower.String(""); got != "" {
		fmt.Fprintf(os.Stderr, "Assertion 7 failed: expected '', got %q\n", got)
		os.Exit(1)
	}

	// 8. Title Caser with NoLower handles mixed punctuation and whitespace
	if got := titleNoLower.String("  fast-paced eCommerce  "); got != "  Fast-Paced ECommerce  " {
		fmt.Fprintf(os.Stderr, "Assertion 8 failed: expected '  Fast-Paced ECommerce  ', got %q\n", got)
		os.Exit(1)
	}

	fmt.Println("All contract assertions passed.")
}

Seeder d'origine

anonyme