샘플
modernc.org/strutil v1.2.1
검증된 샘플 — golang modernc.org/strutil v1.2.1. go 1.26 · linux debian/x64 · docker에서 contract를 실행해 통과했습니다: strutil.NewDict assigns 0 to empty string and…
sha256:0d1932006a15c755e42618b8c4b4b4de629ec39fa8c4f33afcdde17b1257b059
이 네트워크가 제공하는 것은 하나입니다. 빌드되는 샘플. 샌드박스에서 돌리고 서명된 영수증을 보관합니다. 등급을 매기지 않고 무엇도 보증하지 않습니다 — 같은 코드가 당신 환경에서 빌드되는지는 측정한 적이 없습니다.
통과한 계약 영수증을 낸 서로 다른 서명 키의 수입니다. 하나면 작성자 혼자이고, 둘 이상이면 다른 사람도 빌드했다는 뜻입니다. 키는 스스로 만드는 것이고 뒤에 등록된 신원이 없으므로, 세는 것은 사람이 아니라 키입니다.
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-16 |
케이스
HOW- 목표
- verify pkg:golang/modernc.org/strutil@v1.2.1
- 환경
- go 1.26.6
- 생성일
- 2026-09-16T02:17:53Z
컨트랙트
- strutil.NewDict assigns 0 to empty string and positive unique IDs to distinct non-empty strings
- strutil.Dict.S retrieves the original string by its ID and returns true for valid IDs or false for invalid IDs
- strutil.JoinFields joins string slices with delimiter escaping and SplitFields accurately reconstructs the original slice
- strutil.Base64Encode and strutil.Base64Decode roundtrip arbitrary byte sequences without data loss
- strutil.NewPool deduplicates identical strings to return the existing instance and tracks pool count
- strutil.StrPack returns an identical string value packed in memory
파일
- 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/modernc.org/strutil@v1.2.1
Kind: HOW
Use EXACTLY these public packages and versions:
- pkg:golang/modernc.org/strutil@v1.2.1
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:212fe6d10b91dcecef00a9d02409884565179604ec3e6e2758f23384261ba810","contract":["strutil.NewDict assigns 0 to empty string and positive unique IDs to distinct non-empty strings","strutil.Dict.S retrieves the original string by its ID and returns true for valid IDs or false for invalid IDs","strutil.JoinFields joins string slices with delimiter escaping and SplitFields accurately reconstructs the original slice","strutil.Base64Encode and strutil.Base64Decode roundtrip arbitrary byte sequences without data loss","strutil.NewPool deduplicates identical strings to return the existing instance and tracks pool count","strutil.StrPack returns an identical string value packed in memory"],"goal":"verify pkg:golang/modernc.org/strutil@v1.2.1","kind":"HOW","packages":["pkg:golang/modernc.org/strutil@v1.2.1"],"schemaVersion":1},"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/modernc.org/strutil@v1.2.1"],"schemaVersion":1,"subject":"pkg:golang/modernc.org/strutil@v1.2.1","verifierAdapter":"golang@1"}
module sample
go 1.26.6
require modernc.org/strutil v1.2.1
github.com/remyoudompheng/bigfft v0.0.0-20230129092748-24d4a6f8daec h1:W09IVJc94icq4NjY3clb7Lk8O1qJ8BdBEF8z0ibU0rE=
github.com/remyoudompheng/bigfft v0.0.0-20230129092748-24d4a6f8daec/go.mod h1:qqbHyh8v60DhA7CoWK5oRCqLrMHRGoxYCSS9EjAz6Eo=
modernc.org/mathutil v1.7.1 h1:GCZVGXdaN8gTqB1Mf/usp1Y/hSqgI2vAGGP4jZMCxOU=
modernc.org/mathutil v1.7.1/go.mod h1:4p5IwJITfppl0G4sUEDtCr4DthTaT47/N3aT6MhfgJg=
modernc.org/strutil v1.2.1 h1:UneZBkQA+DX2Rp35KcM69cSsNES9ly8mQWD71HKlOA0=
modernc.org/strutil v1.2.1/go.mod h1:EHkiggD70koQxjVdSBM3JKM7k6L0FbGE5eymy9i3B9A=
package main
import (
"fmt"
"modernc.org/strutil"
)
func main() {
// Dict demonstration: string <-> id bijection
dict := strutil.NewDict()
id1 := dict.Id("alpha")
id2 := dict.Id("beta")
s1, _ := dict.S(id1)
s2, _ := dict.S(id2)
fmt.Printf("Dict entries: %d -> %s, %d -> %s (count: %d)\n", id1, s1, id2, s2, dict.Count())
// JoinFields and SplitFields demonstration
parts := []string{"foo", "bar:baz", "qux"}
joined := strutil.JoinFields(parts, ":")
split := strutil.SplitFields(joined, ":")
fmt.Printf("Joined: %s, Split count: %d\n", joined, len(split))
// Base64Encode and Base64Decode demonstration
raw := []byte("CodeSampleX verification")
encoded := strutil.Base64Encode(raw)
decoded, err := strutil.Base64Decode(encoded)
if err != nil {
panic(err)
}
fmt.Printf("Base64: %s -> %s\n", string(encoded), string(decoded))
}
{
"schemaVersion": 1,
"goal": "verify pkg:golang/modernc.org/strutil@v1.2.1",
"kind": "HOW",
"packages": [
"pkg:golang/modernc.org/strutil@v1.2.1"
]
}
package main
import (
"bytes"
"fmt"
"os"
"reflect"
"modernc.org/strutil"
)
func main() {
// Assertion 1: strutil.NewDict assigns 0 to empty string and positive unique IDs to distinct non-empty strings
dict := strutil.NewDict()
if dict == nil {
fmt.Fprintf(os.Stderr, "FAIL assertion 1: NewDict returned nil\n")
os.Exit(1)
}
idEmpty := dict.Id("")
if idEmpty != 0 {
fmt.Fprintf(os.Stderr, "FAIL assertion 1: dict.Id(\"\") = %d, expected 0\n", idEmpty)
os.Exit(1)
}
idAlpha := dict.Id("alpha")
if idAlpha <= 0 {
fmt.Fprintf(os.Stderr, "FAIL assertion 1: dict.Id(\"alpha\") = %d, expected positive integer\n", idAlpha)
os.Exit(1)
}
idBeta := dict.Id("beta")
if idBeta <= 0 || idBeta == idAlpha {
fmt.Fprintf(os.Stderr, "FAIL assertion 1: dict.Id(\"beta\") = %d, expected positive integer distinct from %d\n", idBeta, idAlpha)
os.Exit(1)
}
if idAlpha2 := dict.Id("alpha"); idAlpha2 != idAlpha {
fmt.Fprintf(os.Stderr, "FAIL assertion 1: dict.Id(\"alpha\") second call = %d, expected %d\n", idAlpha2, idAlpha)
os.Exit(1)
}
// Assertion 2: strutil.Dict.S retrieves the original string by its ID and returns true for valid IDs or false for invalid IDs
sEmpty, okEmpty := dict.S(idEmpty)
if !okEmpty || sEmpty != "" {
fmt.Fprintf(os.Stderr, "FAIL assertion 2: dict.S(%d) = (%q, %v), expected (\"\", true)\n", idEmpty, sEmpty, okEmpty)
os.Exit(1)
}
sAlpha, okAlpha := dict.S(idAlpha)
if !okAlpha || sAlpha != "alpha" {
fmt.Fprintf(os.Stderr, "FAIL assertion 2: dict.S(%d) = (%q, %v), expected (\"alpha\", true)\n", idAlpha, sAlpha, okAlpha)
os.Exit(1)
}
sBeta, okBeta := dict.S(idBeta)
if !okBeta || sBeta != "beta" {
fmt.Fprintf(os.Stderr, "FAIL assertion 2: dict.S(%d) = (%q, %v), expected (\"beta\", true)\n", idBeta, sBeta, okBeta)
os.Exit(1)
}
_, okInvalid := dict.S(999999)
if okInvalid {
fmt.Fprintf(os.Stderr, "FAIL assertion 2: dict.S(999999) returned ok=true for nonexistent id\n")
os.Exit(1)
}
if cnt := dict.Count(); cnt != 3 {
fmt.Fprintf(os.Stderr, "FAIL assertion 2: dict.Count() = %d, expected 3\n", cnt)
os.Exit(1)
}
// Assertion 3: strutil.JoinFields joins string slices with delimiter escaping and SplitFields accurately reconstructs the original slice
origFields := []string{"apple", "banana:split", "cherry\\pie", "date", ""}
joined := strutil.JoinFields(origFields, ":")
if len(joined) == 0 {
fmt.Fprintf(os.Stderr, "FAIL assertion 3: JoinFields returned empty string\n")
os.Exit(1)
}
reconstructed := strutil.SplitFields(joined, ":")
if !reflect.DeepEqual(origFields, reconstructed) {
fmt.Fprintf(os.Stderr, "FAIL assertion 3: SplitFields mismatch: got %v, expected %v\n", reconstructed, origFields)
os.Exit(1)
}
// Assertion 4: strutil.Base64Encode and strutil.Base64Decode roundtrip arbitrary byte sequences without data loss
rawPayload := []byte("Testing modernc.org/strutil base64 roundtrip 0123456789!@#$%^&*()_+")
encoded := strutil.Base64Encode(rawPayload)
if len(encoded) == 0 {
fmt.Fprintf(os.Stderr, "FAIL assertion 4: Base64Encode returned empty slice\n")
os.Exit(1)
}
decoded, err := strutil.Base64Decode(encoded)
if err != nil {
fmt.Fprintf(os.Stderr, "FAIL assertion 4: Base64Decode failed: %v\n", err)
os.Exit(1)
}
if !bytes.Equal(rawPayload, decoded) {
fmt.Fprintf(os.Stderr, "FAIL assertion 4: Base64 roundtrip mismatch: got %q, expected %q\n", decoded, rawPayload)
os.Exit(1)
}
_, errInvalidB64 := strutil.Base64Decode([]byte("@@invalid_base64@@"))
if errInvalidB64 == nil {
fmt.Fprintf(os.Stderr, "FAIL assertion 4: expected Base64Decode to return error for invalid data\n")
os.Exit(1)
}
// Assertion 5: strutil.NewPool deduplicates identical strings to return the existing instance and tracks pool count
pool := strutil.NewPool()
if pool == nil {
fmt.Fprintf(os.Stderr, "FAIL assertion 5: NewPool returned nil\n")
os.Exit(1)
}
str1 := pool.Align("pool_sample_string")
str2 := pool.Align("pool_sample_string")
if str1 != "pool_sample_string" || str2 != "pool_sample_string" {
fmt.Fprintf(os.Stderr, "FAIL assertion 5: pool.Align returned unexpected value\n")
os.Exit(1)
}
if pool.Count() != 1 {
fmt.Fprintf(os.Stderr, "FAIL assertion 5: pool.Count() = %d, expected 1\n", pool.Count())
os.Exit(1)
}
pool.Align("different_sample_string")
if pool.Count() != 2 {
fmt.Fprintf(os.Stderr, "FAIL assertion 5: pool.Count() = %d, expected 2\n", pool.Count())
os.Exit(1)
}
// Assertion 6: strutil.StrPack returns an identical string value packed in memory
originalStr := "packed_string_test"
packedStr := strutil.StrPack(originalStr)
if packedStr != originalStr {
fmt.Fprintf(os.Stderr, "FAIL assertion 6: StrPack mismatch: got %q, expected %q\n", packedStr, originalStr)
os.Exit(1)
}
fmt.Println("PASS: all contract assertions passed")
}
오리진 시더
익명