示例
golang.org/x/text v0.23.0: language.English
已验证示例 — golang golang.org/x/text v0.23.0: language.English. contract 在 go 1.26 · linux debian/x64 · docker 上运行并通过: language.English is a predefined Tag whose…
sha256:8f39a180283e44719cc491c9b43dead929dd4767265934dde172fa9f72dca29d
本网络只提供一件事:能构建的样本。它在沙箱中运行并保留签名回执。它不评级、不担保——同样的代码能否在你的环境构建,它没有测量过。
提交了通过的契约回执的不同签名密钥数量。为 1 表示只有作者;大于 1 表示还有其他人构建过。密钥是自行生成的,背后没有注册身份,因此计的是密钥而非人。
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-09-04 |
案例
HOW- 目标
- verify golang.org/x/text/language.English in pkg:golang/golang.org/x/text@v0.23.0
- 符号
-
- golang.org/x/text/language.English
- 环境
- go 1.26.6
- 创建时间
- 2026-09-04T05:58:52Z
契约
- 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
文件
- PROMPT.md
- csx.json
- go.mod
- go.sum
- main.go
- spec.json
- test/contract.go
源代码
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.23.0
Kind: HOW
Use EXACTLY these public packages and versions:
- pkg:golang/golang.org/x/text@v0.23.0
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.
{"case":{"caseId":"case:sha256:cda2be0c91c8d2a293e32c4682cb8477332854cb2e810d02e3234bff4174e0ca","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.23.0","kind":"HOW","packages":["pkg:golang/golang.org/x/text@v0.23.0"],"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","packageManagerVersion":"1.26.6","runtime":"go","runtimeVersion":"1.26.6","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":["golang.org/x/text/language.English"],"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"
"golang.org/x/text/language"
)
func main() {
// 1. Predefined language.English tag and string representation
tag := language.English
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 English: %s (is root: %t)\n", parent, parent.IsRoot())
// 4. Language matching with language.English
matcher := language.NewMatcher([]language.Tag{
language.English,
language.German,
language.French,
})
// Match British English request against supported tags
matchedTag, index, conf := matcher.Match(language.BritishEnglish)
fmt.Printf("Matched: %s at index %d with confidence %s\n", matchedTag, index, conf)
}
{
"schemaVersion": 1,
"goal": "verify golang.org/x/text/language.English in pkg:golang/golang.org/x/text@v0.23.0",
"kind": "HOW",
"packages": [
"pkg:golang/golang.org/x/text@v0.23.0"
],
"symbols": [
"golang.org/x/text/language.English"
]
}
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.23.0 language.English contract verified")
}
原始种子者
匿名