CodeSampleX

Exemplo

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

Amostra verificada para golang golang.org/x/text v0.3.4: language.English. O contrato rodou em go 1.26 · linux debian/x64 · docker e passou.

sha256:e77c000465d96ce7f40203c422490a4c0986f38a26faea93f97eeee1ca1dfa56

Esta rede oferece uma coisa: uma amostra que compila. Ela a executou em um sandbox e guardou o recibo assinado. Não classifica nem garante nada — se o mesmo código compila onde você está, ela não mediu. Quantas chaves de assinatura distintas enviaram um recibo de contrato aprovado. Uma é só o autor; mais de uma significa que outra pessoa também o compilou. Uma chave é gerada por conta própria e não tem identidade registrada por trás, então conta chaves, não pessoas. MIT-0

Evidência de execução

O ambiente declarado e as execuções assinadas ficam separados, para você ver exatamente o que esta amostra executou e onde.

Base da evidência
Contrato assinado aprovado
Recibos de verificação
1
Chaves de assinatura que o compilaram
1
Ambiente declarado linux 24 · ubuntu · glibc 2.39 x64 go go

Ambientes das execuções de verificação

Ambiente Contrato Etapas Execução
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

Caso

HOW
Objetivo
verify golang.org/x/text/language.English in pkg:golang/golang.org/x/text@v0.3.4
Pacotes
Símbolos
  • golang.org/x/text/language.English
Criado
2026-10-22T05:10:11Z

Contrato

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

Arquivos

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

Baixar o artefato de código-fonte (tar.gz)

Código-fonte

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.English 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.English

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

go 1.20

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.English
	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 of English: %s (is root: %t)\n", parent, parent.IsRoot())

	matcher := language.NewMatcher([]language.Tag{
		language.English,
		language.German,
		language.French,
	})

	matchedTag, index, conf := matcher.Match(language.BritishEnglish)
	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.English 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.English"
  ]
}
test/contract.go
package main

import (
	"fmt"
	"os"

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

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

	// Assertion 2: language.English.Base returns Base 'en' with Exact confidence
	base, baseConf := language.English.Base()
	if base.String() != "en" {
		fmt.Fprintf(os.Stderr, "FAIL: expected base 'en', 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.English.Script infers Latin script 'Latn' with High confidence and Region infers 'US' with Low confidence
	script, scriptConf := language.English.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.English.Region()
	if region.String() != "US" {
		fmt.Fprintf(os.Stderr, "FAIL: expected region 'US', 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.English.Parent returns Und root tag with IsRoot true
	parent := language.English.Parent()
	if parent != language.Und {
		fmt.Fprintf(os.Stderr, "FAIL: expected parent of English 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.English matches English regional variants such as BritishEnglish and AmericanEnglish to English
	serverLangs := []language.Tag{
		language.English,
		language.German,
		language.Japanese,
	}
	matcher := language.NewMatcher(serverLangs)

	_, index, conf := matcher.Match(language.BritishEnglish)
	if serverLangs[index] != language.English || index != 0 {
		fmt.Fprintf(os.Stderr, "FAIL: expected BritishEnglish to select serverLangs[0] (English), got index %d\n", index)
		os.Exit(1)
	}
	if conf < language.High {
		fmt.Fprintf(os.Stderr, "FAIL: expected High or Exact confidence for BritishEnglish match, got %v\n", conf)
		os.Exit(1)
	}

	_, indexUS, confUS := matcher.Match(language.AmericanEnglish)
	if serverLangs[indexUS] != language.English || indexUS != 0 {
		fmt.Fprintf(os.Stderr, "FAIL: expected AmericanEnglish to select serverLangs[0] (English), got index %d\n", indexUS)
		os.Exit(1)
	}
	if confUS < language.High {
		fmt.Fprintf(os.Stderr, "FAIL: expected High or Exact confidence for AmericanEnglish match, got %v\n", confUS)
		os.Exit(1)
	}

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

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

Seeder de origem

anônimo