샘플
golang.org/x/text v0.16.0
검증된 샘플 — golang golang.org/x/text v0.16.0. go 1.26 · linux debian/x64 · docker에서 contract를 실행해 통과했습니다: cases.Title and cases.Upper apply locale-sensitive…
sha256:c8ab656318f60ad8001c293b1aab5bdb7dc206f67d2e123302823beea958da09
이 네트워크가 제공하는 것은 하나입니다. 빌드되는 샘플. 샌드박스에서 돌리고 서명된 영수증을 보관합니다. 등급을 매기지 않고 무엇도 보증하지 않습니다 — 같은 코드가 당신 환경에서 빌드되는지는 측정한 적이 없습니다.
통과한 계약 영수증을 낸 서로 다른 서명 키의 수입니다. 하나면 작성자 혼자이고, 둘 이상이면 다른 사람도 빌드했다는 뜻입니다. 키는 스스로 만드는 것이고 뒤에 등록된 신원이 없으므로, 세는 것은 사람이 아니라 키입니다.
MIT-0
실행 증거
선언된 환경과 서명된 실행을 분리해 두었습니다. 이 샘플이 무엇을 어디서 실행했는지 그대로 볼 수 있습니다.
- 증거 기준
- 서명된 컨트랙트 통과
- 검증 영수증
- 1
- 빌드한 서명 키
- 1
선언된 환경
linux 24 · ubuntu · glibc 2.39 x64 go
검증 실행 환경
| 환경 | 컨트랙트 | 단계 | 실행일 |
|---|---|---|---|
| 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-14 |
케이스
HOW- 목표
- verify pkg:golang/golang.org/x/text@v0.16.0
- 생성일
- 2026-09-14T19:21:42Z
컨트랙트
- cases.Title and cases.Upper apply locale-sensitive title and uppercase transformations according to language tags
- language.Match and language.Parse parse BCP 47 tags and select best matching supported language
- norm.NFC and norm.NFD normalize unicode text into canonical composition and decomposition forms
- width.Fold transforms fullwidth characters into standard halfwidth ASCII equivalents
- runes.Map and transform.String transform rune sequences according to custom mapping functions
파일
- 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 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
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:2f90e9aa0fe79cfedc05177cb4686c22e73c33daba69b02abe69d029660b1d68","contract":["cases.Title and cases.Upper apply locale-sensitive title and uppercase transformations according to language tags","language.Match and language.Parse parse BCP 47 tags and select best matching supported language","norm.NFC and norm.NFD normalize unicode text into canonical composition and decomposition forms","width.Fold transforms fullwidth characters into standard halfwidth ASCII equivalents","runes.Map and transform.String transform rune sequences according to custom mapping functions"],"goal":"verify pkg:golang/golang.org/x/text@v0.16.0","kind":"HOW","packages":["pkg:golang/golang.org/x/text@v0.16.0"],"schemaVersion":1},"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","verifierAdapter":"golang@1"}
module example.com/sample
go 1.22
require golang.org/x/text v0.16.0
golang.org/x/text v0.16.0 h1:a94ExnEXNtEwYLGJSIUxnWoxoRz/ZcCsV63ROupILh4=
golang.org/x/text v0.16.0/go.mod h1:GhwF1Be+LQoKShO3cGOHzqOgRrGaYc9AvblQOmPVHnI=
package main
import (
"fmt"
"os"
"unicode"
"golang.org/x/text/cases"
"golang.org/x/text/language"
"golang.org/x/text/runes"
"golang.org/x/text/transform"
"golang.org/x/text/unicode/norm"
"golang.org/x/text/width"
)
// CasingService demonstrates locale-sensitive text casing.
type CasingService struct {
titleCaser cases.Caser
upperCaser cases.Caser
}
// NewCasingService creates a CasingService configured for the specified language tag.
func NewCasingService(tag language.Tag) CasingService {
return CasingService{
titleCaser: cases.Title(tag),
upperCaser: cases.Upper(tag),
}
}
// ToTitle converts text to title case using the service's locale.
func (s CasingService) ToTitle(input string) string {
return s.titleCaser.String(input)
}
// ToUpper converts text to upper case using the service's locale.
func (s CasingService) ToUpper(input string) string {
return s.upperCaser.String(input)
}
// MatchBestLanguage matches user preference against supported server languages.
func MatchBestLanguage(preferred string, supported []language.Tag) language.Tag {
matcher := language.NewMatcher(supported)
userTag, _ := language.Parse(preferred)
matchedTag, _, _ := matcher.Match(userTag)
return matchedTag
}
// NormalizeText applies Unicode NFC or NFD normalization.
func NormalizeText(input string, form norm.Form) string {
return form.String(input)
}
// NormalizeWidth converts fullwidth forms to standard ASCII/halfwidth width.
func NormalizeWidth(input string) string {
return width.Fold.String(input)
}
// MapRunes applies a custom transformation to runes in the input string.
func MapRunes(input string, mapping func(rune) rune) (string, error) {
t := runes.Map(mapping)
result, _, err := transform.String(t, input)
return result, err
}
func main() {
enService := NewCasingService(language.AmericanEnglish)
fmt.Printf("Title (EN): %s\n", enService.ToTitle("the lord of the rings"))
trService := NewCasingService(language.Turkish)
fmt.Printf("Upper (TR): %s\n", trService.ToUpper("istanbul"))
supported := []language.Tag{language.English, language.French, language.German, language.Japanese}
matched := MatchBestLanguage("fr-CA,fr;q=0.9,en;q=0.8", supported)
fmt.Printf("Matched language: %s\n", matched)
decomposed := "e\u0301"
composed := NormalizeText(decomposed, norm.NFC)
fmt.Printf("NFC Composed: %s\n", composed)
fullwidth := "Hello 123!"
halfwidth := NormalizeWidth(fullwidth)
fmt.Printf("Width folded: %s\n", halfwidth)
upperMapped, err := MapRunes("hello world", unicode.ToUpper)
if err != nil {
fmt.Fprintf(os.Stderr, "Rune mapping error: %v\n", err)
os.Exit(1)
}
fmt.Printf("Mapped runes: %s\n", upperMapped)
}
{
"schemaVersion": 1,
"goal": "verify pkg:golang/golang.org/x/text@v0.16.0",
"kind": "HOW",
"packages": [
"pkg:golang/golang.org/x/text@v0.16.0"
]
}
package main
import (
"fmt"
"os"
"unicode"
"golang.org/x/text/cases"
"golang.org/x/text/language"
"golang.org/x/text/runes"
"golang.org/x/text/transform"
"golang.org/x/text/unicode/norm"
"golang.org/x/text/width"
)
func main() {
// Assertion 1: cases.Title and cases.Upper apply locale-sensitive title and uppercase transformations according to language tags
enTitle := cases.Title(language.AmericanEnglish).String("the lord of the rings")
if enTitle != "The Lord Of The Rings" {
fmt.Fprintf(os.Stderr, "FAIL: cases.Title mismatch: got %q\n", enTitle)
os.Exit(1)
}
trUpper := cases.Upper(language.Turkish).String("istanbul")
if trUpper != "İSTANBUL" {
fmt.Fprintf(os.Stderr, "FAIL: cases.Upper Turkish mismatch: got %q\n", trUpper)
os.Exit(1)
}
// Assertion 2: language.Match and language.Parse parse BCP 47 tags and select best matching supported language
supported := []language.Tag{language.English, language.French, language.German}
matcher := language.NewMatcher(supported)
prefTag, err := language.Parse("fr")
if err != nil {
fmt.Fprintf(os.Stderr, "FAIL: language.Parse failed: %v\n", err)
os.Exit(1)
}
matchedTag, _, confidence := matcher.Match(prefTag)
if matchedTag != language.French || confidence == language.No {
fmt.Fprintf(os.Stderr, "FAIL: language.Match unexpected result: tag=%v, confidence=%v\n", matchedTag, confidence)
os.Exit(1)
}
// Assertion 3: norm.NFC and norm.NFD normalize unicode text into canonical composition and decomposition forms
decomposed := "e\u0301" // e + combining acute accent (len 3 in UTF-8)
composed := norm.NFC.String(decomposed)
if composed != "é" || len(composed) != 2 {
fmt.Fprintf(os.Stderr, "FAIL: norm.NFC composition failed: got %q (len %d)\n", composed, len(composed))
os.Exit(1)
}
reDecomposed := norm.NFD.String(composed)
if reDecomposed != decomposed || len(reDecomposed) != 3 {
fmt.Fprintf(os.Stderr, "FAIL: norm.NFD decomposition failed: got %q (len %d)\n", reDecomposed, len(reDecomposed))
os.Exit(1)
}
// Assertion 4: width.Fold transforms fullwidth characters into standard halfwidth ASCII equivalents
fullwidth := "Hello 123!"
folded := width.Fold.String(fullwidth)
expectedFolded := "Hello 123!"
if folded != expectedFolded {
fmt.Fprintf(os.Stderr, "FAIL: width.Fold mismatch: got %q, expected %q\n", folded, expectedFolded)
os.Exit(1)
}
// Assertion 5: runes.Map and transform.String transform rune sequences according to custom mapping functions
mappingTransformer := runes.Map(func(r rune) rune {
if unicode.IsLower(r) {
return unicode.ToUpper(r)
}
return r
})
mappedResult, _, err := transform.String(mappingTransformer, "hello-world-123")
if err != nil {
fmt.Fprintf(os.Stderr, "FAIL: transform.String with runes.Map returned error: %v\n", err)
os.Exit(1)
}
if mappedResult != "HELLO-WORLD-123" {
fmt.Fprintf(os.Stderr, "FAIL: runes.Map result mismatch: got %q\n", mappedResult)
os.Exit(1)
}
fmt.Println("PASS: pkg:golang/golang.org/x/text@v0.16.0 contract verified")
}
오리진 시더
익명