CodeSampleX

샘플

golang.org/x/exp v0.0.0-20251023183803-a4bb9ffd2546

검증된 샘플 — golang golang.org/x/exp v0.0.0-20251023183803-a4bb9ffd2546. go 1.26 · linux alpine/x64 · docker에서 contract를 실행해 통과했습니다.

sha256:4f8750cf652718fc27cfb2e74f20593e1fb969210d69c3447a2c0580e12e337e

이 네트워크가 제공하는 것은 하나입니다. 빌드되는 샘플. 샌드박스에서 돌리고 서명된 영수증을 보관합니다. 등급을 매기지 않고 무엇도 보증하지 않습니다 — 같은 코드가 당신 환경에서 빌드되는지는 측정한 적이 없습니다. 통과한 계약 영수증을 낸 서로 다른 서명 키의 수입니다. 하나면 작성자 혼자이고, 둘 이상이면 다른 사람도 빌드했다는 뜻입니다. 키는 스스로 만드는 것이고 뒤에 등록된 신원이 없으므로, 세는 것은 사람이 아니라 키입니다. MIT-0

실행 증거

선언된 환경과 서명된 실행을 분리해 두었습니다. 이 샘플이 무엇을 어디서 실행했는지 그대로 볼 수 있습니다.

증거 기준
서명된 컨트랙트 통과
검증 영수증
1
빌드한 서명 키
1
선언된 환경 go 1.26 linux 24 · ubuntu · glibc 2.39 x64 go 1.26 go go 1

검증 실행 환경

환경 컨트랙트 단계 실행일
go 1.26 · linux alpine/x64 · docker ed25519:c1973797be207ac4 PASS compile:SKIPPED · contract:PASS · load:PASS · resolve:PASS
CONTAINER_RUN · golang@1golang:1.26-alpine@sha256:28d89ee9cc0f…
2026-08-28

케이스

HOW
목표
verify pkg:golang/golang.org/x/exp@v0.0.0-20251023183803-a4bb9ffd2546
패키지
환경
go 1.26.6
생성일
2026-08-28T10:36:38Z

컨트랙트

  1. utf8string.NewString creates a String wrapper and String() returns the underlying UTF-8 string
  2. String.RuneCount reports the number of Unicode code points rather than byte count
  3. String.IsASCII reports true for ASCII-only strings and false for multi-byte Unicode strings
  4. String.At retrieves the rune at the specified code point index with correct multi-byte decoding
  5. String.Slice extracts substrings by rune boundary indices [i:j]
  6. String.Init resets and initializes an existing String instance with new contents
  7. String.At and String.Slice panic on invalid out-of-range index arguments

파일

  • PROMPT.md
  • contract_test.go
  • csx.json
  • go.mod
  • go.sum
  • spec.json

소스 아티팩트 내려받기 (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 pkg:golang/golang.org/x/exp@v0.0.0-20251023183803-a4bb9ffd2546
Kind: HOW

Use EXACTLY these public packages and versions:
  - pkg:golang/golang.org/x/exp@v0.0.0-20251023183803-a4bb9ffd2546
Required runtime conditions:
  - ecosystem: golang
  - language: go
  - packageManager: go@1.26.6
  - runtime: go@1.26.6

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.
contract_test.go
package sample_test

import (
	"testing"

	"golang.org/x/exp/utf8string"
)

func TestASCIIStringOperations(t *testing.T) {
	str := "Hello, World!"
	s := utf8string.NewString(str)

	if got := s.String(); got != str {
		t.Fatalf("s.String() = %q; want %q", got, str)
	}

	if got := s.RuneCount(); got != 13 {
		t.Fatalf("s.RuneCount() = %d; want 13", got)
	}

	if !s.IsASCII() {
		t.Fatalf("s.IsASCII() = false; want true")
	}

	if got := s.At(0); got != 'H' {
		t.Fatalf("s.At(0) = %q; want 'H'", got)
	}

	if got := s.At(7); got != 'W' {
		t.Fatalf("s.At(7) = %q; want 'W'", got)
	}

	if got := s.At(12); got != '!' {
		t.Fatalf("s.At(12) = %q; want '!'", got)
	}

	if got := s.Slice(0, 5); got != "Hello" {
		t.Fatalf("s.Slice(0, 5) = %q; want %q", got, "Hello")
	}

	if got := s.Slice(7, 12); got != "World" {
		t.Fatalf("s.Slice(7, 12) = %q; want %q", got, "World")
	}

	if got := s.Slice(0, 0); got != "" {
		t.Fatalf("s.Slice(0, 0) = %q; want empty string", got)
	}
}

func TestMultiByteUTF8Operations(t *testing.T) {
	multibyte := "Hello, 世界! 🚀"
	s := utf8string.NewString(multibyte)

	if got := s.String(); got != multibyte {
		t.Fatalf("s.String() = %q; want %q", got, multibyte)
	}

	// 7 ASCII + 2 CJK + 2 ASCII + 1 Emoji = 12 runes
	if got := s.RuneCount(); got != 12 {
		t.Fatalf("s.RuneCount() = %d; want 12", got)
	}

	if s.IsASCII() {
		t.Fatalf("s.IsASCII() = true; want false")
	}

	expectedRunes := []rune{'H', 'e', 'l', 'l', 'o', ',', ' ', '世', '界', '!', ' ', '🚀'}
	for i, want := range expectedRunes {
		if got := s.At(i); got != want {
			t.Fatalf("s.At(%d) = %q (U+%04X); want %q (U+%04X)", i, got, got, want, want)
		}
	}

	if got := s.Slice(7, 9); got != "世界" {
		t.Fatalf("s.Slice(7, 9) = %q; want %q", got, "世界")
	}

	if got := s.Slice(0, 7); got != "Hello, " {
		t.Fatalf("s.Slice(0, 7) = %q; want %q", got, "Hello, ")
	}

	if got := s.Slice(9, 12); got != "! 🚀" {
		t.Fatalf("s.Slice(9, 12) = %q; want %q", got, "! 🚀")
	}

	if got := s.Slice(11, 12); got != "🚀" {
		t.Fatalf("s.Slice(11, 12) = %q; want %q", got, "🚀")
	}
}

func TestBidirectionalAndRandomAccess(t *testing.T) {
	s := utf8string.NewString("alpha, beta, gamma: αβγ 123")
	expected := []rune("alpha, beta, gamma: αβγ 123")

	// Backward scan
	for i := len(expected) - 1; i >= 0; i-- {
		if got := s.At(i); got != expected[i] {
			t.Fatalf("backward scan s.At(%d) = %q; want %q", i, got, expected[i])
		}
	}

	// Random jump access
	indices := []int{20, 2, 21, 0, 19, 25, 5, 22}
	for _, idx := range indices {
		if got := s.At(idx); got != expected[idx] {
			t.Fatalf("random jump s.At(%d) = %q; want %q", idx, got, expected[idx])
		}
	}
}

func TestInitReusability(t *testing.T) {
	var s utf8string.String
	s.Init("Go 언어")

	if got := s.RuneCount(); got != 5 {
		t.Fatalf("s.RuneCount() = %d; want 5", got)
	}
	if s.IsASCII() {
		t.Fatalf("s.IsASCII() = true; want false")
	}
	if got := s.At(3); got != '언' {
		t.Fatalf("s.At(3) = %q; want '언'", got)
	}
	if got := s.Slice(0, 2); got != "Go" {
		t.Fatalf("s.Slice(0, 2) = %q; want %q", got, "Go")
	}

	// Reinitialize with ASCII string
	s.Init("golang")
	if got := s.RuneCount(); got != 6 {
		t.Fatalf("re-init s.RuneCount() = %d; want 6", got)
	}
	if !s.IsASCII() {
		t.Fatalf("re-init s.IsASCII() = false; want true")
	}
	if got := s.String(); got != "golang" {
		t.Fatalf("re-init s.String() = %q; want %q", got, "golang")
	}
}

func TestPanicConditions(t *testing.T) {
	s := utf8string.NewString("test 世界")

	assertPanic := func(name string, fn func()) {
		defer func() {
			if r := recover(); r == nil {
				t.Fatalf("%s expected panic, but did not panic", name)
			}
		}()
		fn()
	}

	assertPanic("At negative index", func() {
		s.At(-1)
	})

	assertPanic("At index equal to rune count", func() {
		s.At(s.RuneCount())
	})

	assertPanic("Slice inverted indices", func() {
		s.Slice(4, 2)
	})

	assertPanic("Slice end index beyond rune count", func() {
		s.Slice(0, s.RuneCount()+1)
	})
}
csx.json
{"case":{"caseId":"case:sha256:6a3698fa28e1b800c5dbec505fd5e649746635cbbc74bdb23952e64d5a21be5b","contract":["utf8string.NewString creates a String wrapper and String() returns the underlying UTF-8 string","String.RuneCount reports the number of Unicode code points rather than byte count","String.IsASCII reports true for ASCII-only strings and false for multi-byte Unicode strings","String.At retrieves the rune at the specified code point index with correct multi-byte decoding","String.Slice extracts substrings by rune boundary indices [i:j]","String.Init resets and initializes an existing String instance with new contents","String.At and String.Slice panic on invalid out-of-range index arguments"],"goal":"verify pkg:golang/golang.org/x/exp@v0.0.0-20251023183803-a4bb9ffd2546","kind":"HOW","packages":["pkg:golang/golang.org/x/exp@v0.0.0-20251023183803-a4bb9ffd2546"],"schemaVersion":1},"contractCommand":["go","test","-v","./..."],"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/exp@v0.0.0-20251023183803-a4bb9ffd2546"],"schemaVersion":1,"subject":"pkg:golang/golang.org/x/exp@v0.0.0-20251023183803-a4bb9ffd2546","verifierAdapter":"golang@1"}
go.mod
module sample

go 1.24.0

require golang.org/x/exp v0.0.0-20251023183803-a4bb9ffd2546
go.sum
golang.org/x/exp v0.0.0-20251023183803-a4bb9ffd2546 h1:mgKeJMpvi0yx/sU5GsxQ7p6s2wtOnGAHZWCHUM4KGzY=
golang.org/x/exp v0.0.0-20251023183803-a4bb9ffd2546/go.mod h1:j/pmGrbnkbPtQfxEe5D0VQhZC6qKbfKifgD0oM7sR70=
spec.json
{
  "schemaVersion": 1,
  "goal": "verify pkg:golang/golang.org/x/exp@v0.0.0-20251023183803-a4bb9ffd2546",
  "kind": "HOW",
  "packages": [
    "pkg:golang/golang.org/x/exp@v0.0.0-20251023183803-a4bb9ffd2546"
  ],
  "runtimeConditions": {
    "ecosystem": "golang",
    "language": "go",
    "packageManager": "go@1.26.6",
    "runtime": "go@1.26.6"
  }
}

오리진 시더

익명