CodeSampleX

Пример

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

Проверенный пример — golang golang.org/x/text v0.3.4: language.German. Контракт выполнен на go 1.26 · linux debian/x64 · docker и пройден.

sha256:166d74cdede353e9696b2bebd58ba23529591aa07a8f72cda27275c48c955d18

Эта сеть предлагает одно: образец, который собирается. Она запустила его в песочнице и сохранила подписанную квитанцию. Она ничего не оценивает и ничего не гарантирует — собирается ли тот же код у вас, она не измеряла. Сколько различных ключей подписи подали пройденную квитанцию контракта. Один — только автор; больше одного — значит, кто-то ещё тоже собрал. Ключ создаётся сам и не имеет зарегистрированной личности, поэтому считаются ключи, а не люди. MIT-0

Свидетельства выполнения

Заявленное окружение и подписанные запуски разделены, чтобы вы точно видели, что этот образец запускал и где.

Основа свидетельства
Подписанный контракт пройден
Квитанции проверки
1
Ключи подписи, собравшие его
1
Заявленная среда go 1.26 linux 24 · ubuntu · glibc 2.39 x64 go 1.26 go go 1

Среды запусков проверки

Окружение Контракт Этапы Запуск
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-10-22

Кейс

HOW
Цель
verify golang.org/x/text/language.German in pkg:golang/golang.org/x/text@v0.3.4
Пакеты
Символы
  • golang.org/x/text/language.German
Окружение
go 1.26.6
Создан
2026-10-22T14:15:53Z

Контракт

  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

Файлы

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

Скачать артефакт с исходным кодом (tar.gz)

Исходный код

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.3.4
Kind: HOW

Use EXACTLY these public packages and versions:
  - pkg:golang/golang.org/x/text@v0.3.4
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:668e885b11c8bd739424a822cdffd93a91e0a303f353b9aeb28ee76e3437febd","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.3.4","kind":"HOW","packages":["pkg:golang/golang.org/x/text@v0.3.4"],"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.3.4"],"schemaVersion":1,"subject":"pkg:golang/golang.org/x/text@v0.3.4","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.3.4
go.sum
golang.org/x/text v0.3.4 h1:0YWbFKbhXG/wIiuHDSKpS0Iy7FSA+u45VtBMfQcFTTc=
golang.org/x/text v0.3.4/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
main.go
package main

import (
	"fmt"

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

func main() {
	tag := language.German
	fmt.Printf("Tag: %s\n", tag.String())

	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)

	parent := tag.Parent()
	fmt.Printf("Parent: %s (isRoot: %t)\n", parent, parent.IsRoot())

	matcher := language.NewMatcher([]language.Tag{
		language.English,
		language.German,
		language.French,
	})
	matched, idx, conf := matcher.Match(language.Make("de-AT"))
	fmt.Printf("Matched de-AT: %s (index %d, confidence %s)\n", matched, idx, conf)
}
spec.json
{
  "schemaVersion": 1,
  "goal": "verify golang.org/x/text/language.German in pkg:golang/golang.org/x/text@v0.3.4",
  "kind": "HOW",
  "packages": [
    "pkg:golang/golang.org/x/text@v0.3.4"
  ],
  "symbols": [
    "golang.org/x/text/language.German"
  ]
}
test/contract.go
package main

import (
	"fmt"
	"os"

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

func main() {
	// 1. Verify language.German is a predefined Tag with string representation "de" and equals language.Make("de")
	if got := language.German.String(); got != "de" {
		fmt.Fprintf(os.Stderr, "expected language.German.String() == \"de\", got %q\n", got)
		os.Exit(1)
	}
	if parsed := language.Make("de"); parsed != language.German {
		fmt.Fprintf(os.Stderr, "expected language.Make(\"de\") == language.German, got %v\n", parsed)
		os.Exit(1)
	}

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

	// 3. Verify language.German.Script() infers "Latn" (High) and Region() infers "DE" (Low)
	script, scriptConf := language.German.Script()
	if script.String() != "Latn" || scriptConf != language.High {
		fmt.Fprintf(os.Stderr, "expected Script() == (Latn, High), got (%s, %v)\n", script, scriptConf)
		os.Exit(1)
	}
	region, regionConf := language.German.Region()
	if region.String() != "DE" || regionConf != language.Low {
		fmt.Fprintf(os.Stderr, "expected Region() == (DE, Low), got (%s, %v)\n", region, regionConf)
		os.Exit(1)
	}

	// 4. Verify language.German.Parent() is language.Und and IsRoot() is true
	parent := language.German.Parent()
	if parent != language.Und || !parent.IsRoot() {
		fmt.Fprintf(os.Stderr, "expected Parent() == Und with IsRoot() == true, got %v (isRoot=%t)\n", parent, parent.IsRoot())
		os.Exit(1)
	}

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

	for _, variant := range []string{"de-AT", "de-CH"} {
		req := language.Make(variant)
		_, idx, conf := matcher.Match(req)
		if idx != 1 || supported[idx] != language.German {
			fmt.Fprintf(os.Stderr, "expected %s to match German at index 1, got index %d (%v)\n", variant, idx, supported[idx])
			os.Exit(1)
		}
		if conf < language.High {
			fmt.Fprintf(os.Stderr, "expected High or Exact confidence for %s, got %v\n", variant, conf)
			os.Exit(1)
		}
	}

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

Исходный сидер

аноним