CodeSampleX

Exemple

golang.org/x/text v0.16.0: language.German

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

sha256:ae9dd3d6bc83eb4012922a6be1b7f6ad7d1a2ffbc2deb2270d2d0d299801f01a

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é go 1.26 linux 24 · ubuntu · glibc 2.39 x64 go 1.26 go go 1

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/language.German in pkg:golang/golang.org/x/text@v0.16.0
Paquets
Symboles
  • golang.org/x/text/language.German
Environnement
go 1.26.6
Créé
2026-09-15T03:48:38Z

Contrat

  1. language.German is a predefined Tag whose String representation equals 'de' and equals language.Make('de')
  2. language.German.Base returns Base 'de' with Exact confidence
  3. language.German.Script infers Latin script 'Latn' with High confidence and Region infers 'DE' with Low confidence
  4. language.German.Parent returns Und root tag with IsRoot true
  5. language.NewMatcher with language.German matches German regional variants such as de-AT and de-CH to German

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/language.German 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/language.German

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:95ff9a17dce458bc5bee0ae7131905c713a0bef4ff5afa53049915a839964130","contract":["language.German is a predefined Tag whose String representation equals 'de' and equals language.Make('de')","language.German.Base returns Base 'de' with Exact confidence","language.German.Script infers Latin script 'Latn' with High confidence and Region infers 'DE' with Low confidence","language.German.Parent returns Und root tag with IsRoot true","language.NewMatcher with language.German matches German regional variants such as de-AT and de-CH to German"],"goal":"verify golang.org/x/text/language.German 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/language.German"]},"contractCommand":["go","run","./test"],"environment":{"arch":"x64","distro":"ubuntu","ecosystem":"golang","language":"go","libc":"glibc","libcVersion":"2.39","os":"linux","osVersionBucket":"24","packageManager":"go","packageManagerVersion":"1.26.6","runtime":"go","runtimeVersion":"1.26.6","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/language.German"],"verifierAdapter":"golang@1"}
go.mod
module example.com/sample

go 1.26.0

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/language"
)

func main() {
	// 1. Predefined language.German tag and string representation
	tag := language.German
	fmt.Printf("Tag: %s\n", tag.String())

	// 2. Base language, script, and region extraction
	base, baseConf := tag.Base()
	script, scriptConf := tag.Script()
	region, regionConf := tag.Region()
	fmt.Printf("Base: %s (%s), Script: %s (%s), Region: %s (%s)\n",
		base, baseConf, script, scriptConf, region, regionConf)

	// 3. Parent language tag in CLDR hierarchy
	parent := tag.Parent()
	fmt.Printf("Parent of German: %s (is root: %t)\n", parent, parent.IsRoot())

	// 4. Language matching with language.German
	matcher := language.NewMatcher([]language.Tag{
		language.English,
		language.German,
		language.French,
	})

	// Match Austrian German request against supported tags
	matchedTag, index, conf := matcher.Match(language.Make("de-AT"))
	fmt.Printf("Matched: %s at index %d with confidence %s\n", matchedTag, index, conf)
}
spec.json
{
  "schemaVersion": 1,
  "goal": "verify golang.org/x/text/language.German 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/language.German"
  ]
}
test/contract.go
package main

import (
	"fmt"
	"os"

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

func main() {
	// Assertion 1: language.German is a predefined Tag whose String representation equals "de" and equals language.Make("de")
	if tagStr := language.German.String(); tagStr != "de" {
		fmt.Fprintf(os.Stderr, "FAIL: expected language.German.String() to be 'de', got %q\n", tagStr)
		os.Exit(1)
	}
	if parsed := language.Make("de"); parsed != language.German {
		fmt.Fprintf(os.Stderr, "FAIL: expected language.Make('de') to equal language.German\n")
		os.Exit(1)
	}

	// Assertion 2: language.German.Base returns Base "de" with Exact confidence
	base, baseConf := language.German.Base()
	if base.String() != "de" {
		fmt.Fprintf(os.Stderr, "FAIL: expected base 'de', got %q\n", base.String())
		os.Exit(1)
	}
	if baseConf != language.Exact {
		fmt.Fprintf(os.Stderr, "FAIL: expected Exact confidence for base, got %v\n", baseConf)
		os.Exit(1)
	}

	// Assertion 3: language.German.Script infers Latin script "Latn" with High confidence and Region infers "DE" with Low confidence
	script, scriptConf := language.German.Script()
	if script.String() != "Latn" {
		fmt.Fprintf(os.Stderr, "FAIL: expected script 'Latn', got %q\n", script.String())
		os.Exit(1)
	}
	if scriptConf != language.High {
		fmt.Fprintf(os.Stderr, "FAIL: expected High confidence for inferred script, got %v\n", scriptConf)
		os.Exit(1)
	}

	region, regionConf := language.German.Region()
	if region.String() != "DE" {
		fmt.Fprintf(os.Stderr, "FAIL: expected region 'DE', got %q\n", region.String())
		os.Exit(1)
	}
	if regionConf != language.Low {
		fmt.Fprintf(os.Stderr, "FAIL: expected Low confidence for inferred region, got %v\n", regionConf)
		os.Exit(1)
	}

	// Assertion 4: language.German.Parent returns Und root tag with IsRoot true
	parent := language.German.Parent()
	if parent != language.Und {
		fmt.Fprintf(os.Stderr, "FAIL: expected parent of German to be Und, got %v\n", parent)
		os.Exit(1)
	}
	if !parent.IsRoot() {
		fmt.Fprintf(os.Stderr, "FAIL: expected parent.IsRoot() to be true\n")
		os.Exit(1)
	}

	// Assertion 5: language.NewMatcher with language.German matches German regional variants such as de-AT and de-CH to German
	serverLangs := []language.Tag{
		language.English,
		language.German,
		language.French,
	}
	matcher := language.NewMatcher(serverLangs)

	deAT := language.Make("de-AT")
	_, indexAT, confAT := matcher.Match(deAT)
	if serverLangs[indexAT] != language.German || indexAT != 1 {
		fmt.Fprintf(os.Stderr, "FAIL: expected de-AT to select serverLangs[1] (German), got index %d\n", indexAT)
		os.Exit(1)
	}
	if confAT < language.High {
		fmt.Fprintf(os.Stderr, "FAIL: expected High or Exact confidence for de-AT match, got %v\n", confAT)
		os.Exit(1)
	}

	deCH := language.Make("de-CH")
	_, indexCH, confCH := matcher.Match(deCH)
	if serverLangs[indexCH] != language.German || indexCH != 1 {
		fmt.Fprintf(os.Stderr, "FAIL: expected de-CH to select serverLangs[1] (German), got index %d\n", indexCH)
		os.Exit(1)
	}
	if confCH < language.High {
		fmt.Fprintf(os.Stderr, "FAIL: expected High or Exact confidence for de-CH match, got %v\n", confCH)
		os.Exit(1)
	}

	if comp := language.Comprehends(deAT, language.German); comp < language.High {
		fmt.Fprintf(os.Stderr, "FAIL: expected High comprehension between de-AT and German, got %v\n", comp)
		os.Exit(1)
	}

	fmt.Println("PASS: pkg:golang/golang.org/x/text@v0.16.0 language.German contract verified")
}

Seeder d'origine

anonyme