샘플
golang.org/x/text v0.42.0: encoding.Nop
검증된 샘플 — golang golang.org/x/text v0.42.0: encoding.Nop. go 1.26 · linux debian/x64 · docker에서 contract를 실행해 통과했습니다: encoding.Nop.NewDecoder returns a…
sha256:e1aac7a48a1039b506efca74be1858514422c3485143654ef60d0014925a36e1
이 네트워크가 제공하는 것은 하나입니다. 빌드되는 샘플. 샌드박스에서 돌리고 서명된 영수증을 보관합니다. 등급을 매기지 않고 무엇도 보증하지 않습니다 — 같은 코드가 당신 환경에서 빌드되는지는 측정한 적이 없습니다.
통과한 계약 영수증을 낸 서로 다른 서명 키의 수입니다. 하나면 작성자 혼자이고, 둘 이상이면 다른 사람도 빌드했다는 뜻입니다. 키는 스스로 만드는 것이고 뒤에 등록된 신원이 없으므로, 세는 것은 사람이 아니라 키입니다.
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:d91480838ac982c9 | PASS | compile:SKIPPED · contract:PASS · load:PASS · resolve:PASS CONTAINER_RUN · golang@1golang:1.26@sha256:e30143be198a… |
2026-09-15 |
케이스
HOW- 목표
- verify golang.org/x/text/encoding.Nop in pkg:golang/golang.org/x/text@v0.42.0
- 심벌
-
- golang.org/x/text/encoding.Nop
- 환경
- go 1.26.6
- 생성일
- 2026-09-15T21:22:28Z
컨트랙트
- encoding.Nop.NewDecoder returns a Decoder whose Bytes and String methods preserve input bytes and strings unchanged
- encoding.Nop.NewEncoder returns an Encoder whose Bytes and String methods preserve input bytes and strings unchanged
- encoding.Nop decoder and encoder pass invalid UTF-8 byte sequences through without error or replacement
- encoding.Nop.NewDecoder Reader wraps an io.Reader and reads the underlying byte stream unchanged
- encoding.Nop.NewEncoder Writer wraps an io.Writer and writes the byte stream unchanged
파일
- 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/encoding.Nop in pkg:golang/golang.org/x/text@v0.42.0
Kind: HOW
Use EXACTLY these public packages and versions:
- pkg:golang/golang.org/x/text@v0.42.0
Demonstrate these symbols/APIs:
- golang.org/x/text/encoding.Nop
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:7b0988dc655982b79194de8755a57e126321b09967164ba301b13fdb84a50387","contract":["encoding.Nop.NewDecoder returns a Decoder whose Bytes and String methods preserve input bytes and strings unchanged","encoding.Nop.NewEncoder returns an Encoder whose Bytes and String methods preserve input bytes and strings unchanged","encoding.Nop decoder and encoder pass invalid UTF-8 byte sequences through without error or replacement","encoding.Nop.NewDecoder Reader wraps an io.Reader and reads the underlying byte stream unchanged","encoding.Nop.NewEncoder Writer wraps an io.Writer and writes the byte stream unchanged"],"goal":"verify golang.org/x/text/encoding.Nop in pkg:golang/golang.org/x/text@v0.42.0","kind":"HOW","packages":["pkg:golang/golang.org/x/text@v0.42.0"],"schemaVersion":1,"symbols":["golang.org/x/text/encoding.Nop"]},"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.42.0"],"schemaVersion":1,"subject":"pkg:golang/golang.org/x/text@v0.42.0","symbols":["golang.org/x/text/encoding.Nop"],"verifierAdapter":"golang@1"}
module sample
go 1.26.6
require golang.org/x/text v0.42.0
golang.org/x/text v0.42.0 h1:JbOZXgfeCPU9gacVtYliJqOhD+zhrEqK4LfdpmlUZqI=
golang.org/x/text v0.42.0/go.mod h1:ojzP1Z+2QtioaF8DTtO8K5q7JWVVYwZKenzujK0Zd0E=
package main
import (
"bytes"
"fmt"
"io"
"strings"
"golang.org/x/text/encoding"
)
func main() {
// Demonstrating golang.org/x/text/encoding.Nop
// encoding.Nop is the nop encoding whose transformed bytes are identical to source bytes.
// 1. Using NewDecoder to decode bytes and strings
decoder := encoding.Nop.NewDecoder()
decodedBytes, err := decoder.Bytes([]byte("Hello, World!"))
if err != nil {
fmt.Printf("Decode error: %v\n", err)
return
}
fmt.Printf("Decoded bytes: %s\n", string(decodedBytes))
decodedStr, err := decoder.String("Sample text: 12345")
if err != nil {
fmt.Printf("Decode string error: %v\n", err)
return
}
fmt.Printf("Decoded string: %s\n", decodedStr)
// 2. Using NewEncoder to encode bytes and strings
encoder := encoding.Nop.NewEncoder()
encodedBytes, err := encoder.Bytes([]byte("Sample payload"))
if err != nil {
fmt.Printf("Encode error: %v\n", err)
return
}
fmt.Printf("Encoded bytes: %s\n", string(encodedBytes))
encodedStr, err := encoder.String("Encoded string text")
if err != nil {
fmt.Printf("Encode string error: %v\n", err)
return
}
fmt.Printf("Encoded string: %s\n", encodedStr)
// 3. Streaming with Reader and Writer
reader := decoder.Reader(strings.NewReader("Stream content through Nop decoder"))
streamResult, err := io.ReadAll(reader)
if err != nil {
fmt.Printf("Reader stream error: %v\n", err)
return
}
fmt.Printf("Reader stream output: %s\n", string(streamResult))
var buf bytes.Buffer
writer := encoder.Writer(&buf)
_, err = writer.Write([]byte("Stream content through Nop encoder"))
if err != nil {
fmt.Printf("Writer stream error: %v\n", err)
return
}
fmt.Printf("Writer stream output: %s\n", buf.String())
// 4. Invalid UTF-8 bytes are preserved without modification
rawSeq := []byte{0xff, 0xfe, 0xfd}
passthrough, err := decoder.Bytes(rawSeq)
if err != nil {
fmt.Printf("Invalid UTF-8 passthrough error: %v\n", err)
return
}
fmt.Printf("Invalid sequence length preserved: %d\n", len(passthrough))
fmt.Println("golang.org/x/text/encoding.Nop demonstrated successfully.")
}
{
"schemaVersion": 1,
"goal": "verify golang.org/x/text/encoding.Nop in pkg:golang/golang.org/x/text@v0.42.0",
"kind": "HOW",
"packages": [
"pkg:golang/golang.org/x/text@v0.42.0"
],
"symbols": [
"golang.org/x/text/encoding.Nop"
]
}
package main
import (
"bytes"
"fmt"
"io"
"os"
"strings"
"golang.org/x/text/encoding"
)
func main() {
// Assertion 1: encoding.Nop.NewDecoder returns a Decoder whose Bytes and String methods preserve input bytes and strings unchanged
{
decoder := encoding.Nop.NewDecoder()
if decoder == nil {
fmt.Fprintf(os.Stderr, "assertion 1 failed: NewDecoder returned nil\n")
os.Exit(1)
}
inputBytes := []byte("Standard UTF-8 text for decoding: 12345 @#$")
outBytes, err := decoder.Bytes(inputBytes)
if err != nil {
fmt.Fprintf(os.Stderr, "assertion 1 failed: Bytes returned error: %v\n", err)
os.Exit(1)
}
if !bytes.Equal(outBytes, inputBytes) {
fmt.Fprintf(os.Stderr, "assertion 1 failed: Bytes did not preserve input byte slice\n")
os.Exit(1)
}
inputStr := "Sample string value with unicode: 你好 세계"
outStr, err := decoder.String(inputStr)
if err != nil {
fmt.Fprintf(os.Stderr, "assertion 1 failed: String returned error: %v\n", err)
os.Exit(1)
}
if outStr != inputStr {
fmt.Fprintf(os.Stderr, "assertion 1 failed: String did not preserve input string\n")
os.Exit(1)
}
}
// Assertion 2: encoding.Nop.NewEncoder returns an Encoder whose Bytes and String methods preserve input bytes and strings unchanged
{
encoder := encoding.Nop.NewEncoder()
if encoder == nil {
fmt.Fprintf(os.Stderr, "assertion 2 failed: NewEncoder returned nil\n")
os.Exit(1)
}
inputBytes := []byte("Standard UTF-8 text for encoding: 67890 %^&*")
outBytes, err := encoder.Bytes(inputBytes)
if err != nil {
fmt.Fprintf(os.Stderr, "assertion 2 failed: Bytes returned error: %v\n", err)
os.Exit(1)
}
if !bytes.Equal(outBytes, inputBytes) {
fmt.Fprintf(os.Stderr, "assertion 2 failed: Bytes did not preserve input byte slice\n")
os.Exit(1)
}
inputStr := "Sample encoded string: Привет мир"
outStr, err := encoder.String(inputStr)
if err != nil {
fmt.Fprintf(os.Stderr, "assertion 2 failed: String returned error: %v\n", err)
os.Exit(1)
}
if outStr != inputStr {
fmt.Fprintf(os.Stderr, "assertion 2 failed: String did not preserve input string\n")
os.Exit(1)
}
}
// Assertion 3: encoding.Nop decoder and encoder pass invalid UTF-8 byte sequences through without error or replacement
{
decoder := encoding.Nop.NewDecoder()
encoder := encoding.Nop.NewEncoder()
// Invalid UTF-8 byte sequence
invalidBytes := []byte{0xff, 0xfe, 0x80, 0xc0, 0xaf, 0x00}
decOut, err := decoder.Bytes(invalidBytes)
if err != nil {
fmt.Fprintf(os.Stderr, "assertion 3 failed: decoder returned error on invalid UTF-8: %v\n", err)
os.Exit(1)
}
if !bytes.Equal(decOut, invalidBytes) {
fmt.Fprintf(os.Stderr, "assertion 3 failed: decoder modified invalid UTF-8 byte sequence\n")
os.Exit(1)
}
encOut, err := encoder.Bytes(invalidBytes)
if err != nil {
fmt.Fprintf(os.Stderr, "assertion 3 failed: encoder returned error on invalid UTF-8: %v\n", err)
os.Exit(1)
}
if !bytes.Equal(encOut, invalidBytes) {
fmt.Fprintf(os.Stderr, "assertion 3 failed: encoder modified invalid UTF-8 byte sequence\n")
os.Exit(1)
}
}
// Assertion 4: encoding.Nop.NewDecoder Reader wraps an io.Reader and reads the underlying byte stream unchanged
{
content := "Stream reader payload content with multi-line\nand special symbols."
rawReader := strings.NewReader(content)
wrappedReader := encoding.Nop.NewDecoder().Reader(rawReader)
readBytes, err := io.ReadAll(wrappedReader)
if err != nil {
fmt.Fprintf(os.Stderr, "assertion 4 failed: io.ReadAll returned error: %v\n", err)
os.Exit(1)
}
if string(readBytes) != content {
fmt.Fprintf(os.Stderr, "assertion 4 failed: wrapped Reader did not return exact source content\n")
os.Exit(1)
}
}
// Assertion 5: encoding.Nop.NewEncoder Writer wraps an io.Writer and writes the byte stream unchanged
{
content := []byte("Stream writer binary and text payload: \x00\x01\x02 testing 123")
var buf bytes.Buffer
wrappedWriter := encoding.Nop.NewEncoder().Writer(&buf)
n, err := wrappedWriter.Write(content)
if err != nil {
fmt.Fprintf(os.Stderr, "assertion 5 failed: Write returned error: %v\n", err)
os.Exit(1)
}
if n != len(content) {
fmt.Fprintf(os.Stderr, "assertion 5 failed: Write returned count %d, expected %d\n", n, len(content))
os.Exit(1)
}
if !bytes.Equal(buf.Bytes(), content) {
fmt.Fprintf(os.Stderr, "assertion 5 failed: wrapped Writer did not write exact source bytes\n")
os.Exit(1)
}
}
fmt.Println("All contract assertions passed successfully.")
}
오리진 시더
익명