샘플
github.com/chzyer/readline v1.5.1: Config
검증된 샘플 — golang github.com/chzyer/readline v1.5.1: Config. go 1.26 · linux debian/x64 · docker에서 contract를 실행해 통과했습니다: readline.Config.Init establishes…
sha256:9759d6707465ad5c5b3b8959b93809f94a69abeef62bcac92be2c0a4ce17db37
이 네트워크가 제공하는 것은 하나입니다. 빌드되는 샘플. 샌드박스에서 돌리고 서명된 영수증을 보관합니다. 등급을 매기지 않고 무엇도 보증하지 않습니다 — 같은 코드가 당신 환경에서 빌드되는지는 측정한 적이 없습니다.
통과한 계약 영수증을 낸 서로 다른 서명 키의 수입니다. 하나면 작성자 혼자이고, 둘 이상이면 다른 사람도 빌드했다는 뜻입니다. 키는 스스로 만드는 것이고 뒤에 등록된 신원이 없으므로, 세는 것은 사람이 아니라 키입니다.
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-06 |
케이스
HOW- 목표
- verify github.com/chzyer/readline.Config in pkg:golang/github.com/chzyer/readline@v1.5.1
- 심벌
-
- github.com/chzyer/readline.Config
- 생성일
- 2026-09-06T01:39:30Z
컨트랙트
- readline.Config.Init establishes default parameters including HistoryLimit and interrupt prompts
- readline.Config.Clone yields an independent configuration instance preserving settings
- readline.Config.SetListener registers custom input event hook callback on configuration
- readline.Config.SetPainter attaches custom syntax and display painter to configuration
- readline.Config with FuncFilterInputRune intercepts and transforms input stream runes
- readline.Config with UniqueEditLine and VimMode configures editor mode and line persistence flags
파일
- 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 github.com/chzyer/readline.Config in pkg:golang/github.com/chzyer/readline@v1.5.1
Kind: HOW
Use EXACTLY these public packages and versions:
- pkg:golang/github.com/chzyer/readline@v1.5.1
Demonstrate these symbols/APIs:
- github.com/chzyer/readline.Config
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:8147b984c3d370f75f75cefb91211372b6b35dcb735d68320e53e642d5c60701","contract":["readline.Config.Init establishes default parameters including HistoryLimit and interrupt prompts","readline.Config.Clone yields an independent configuration instance preserving settings","readline.Config.SetListener registers custom input event hook callback on configuration","readline.Config.SetPainter attaches custom syntax and display painter to configuration","readline.Config with FuncFilterInputRune intercepts and transforms input stream runes","readline.Config with UniqueEditLine and VimMode configures editor mode and line persistence flags"],"goal":"verify github.com/chzyer/readline.Config in pkg:golang/github.com/chzyer/readline@v1.5.1","kind":"HOW","packages":["pkg:golang/github.com/chzyer/readline@v1.5.1"],"schemaVersion":1,"symbols":["github.com/chzyer/readline.Config"]},"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/github.com/chzyer/readline@v1.5.1"],"schemaVersion":1,"subject":"pkg:golang/github.com/chzyer/readline@v1.5.1","symbols":["github.com/chzyer/readline.Config"],"verifierAdapter":"golang@1"}
module sample
go 1.26.6
require github.com/chzyer/readline v1.5.1
require golang.org/x/sys v0.0.0-20220310020820-b874c991c1a5 // indirect
github.com/chzyer/logex v1.2.1 h1:XHDu3E6q+gdHgsdTPH6ImJMIp436vR6MPtH8gP05QzM=
github.com/chzyer/logex v1.2.1/go.mod h1:JLbx6lG2kDbNRFnfkgvh4eRJRPX1QCoOIWomwysCBrQ=
github.com/chzyer/readline v1.5.1 h1:upd/6fQk4src78LMRzh5vItIt361/o4uq553V8B5sGI=
github.com/chzyer/readline v1.5.1/go.mod h1:Eh+b79XXUwfKfcPLepksvw2tcLE/Ct21YObkaSkeBlk=
github.com/chzyer/test v1.0.0 h1:p3BQDXSxOhOG0P9z6/hGnII4LGiEPOYBhs8asl/fC04=
github.com/chzyer/test v1.0.0/go.mod h1:2JlltgoNkt4TW/z9V/IzDdFaMTM2JPIi26O1pF38GC8=
golang.org/x/sys v0.0.0-20220310020820-b874c991c1a5 h1:y/woIyUBFbpQGKS0u1aHF/40WUDnek3fPOyD08H5Vng=
golang.org/x/sys v0.0.0-20220310020820-b874c991c1a5/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
package main
import (
"bytes"
"fmt"
"io"
"strings"
"github.com/chzyer/readline"
)
// HighlightPainter implements readline.Painter to format line input.
type HighlightPainter struct{}
func (hp *HighlightPainter) Paint(line []rune, pos int) []rune {
return line
}
func main() {
// Configure readline instance with custom settings
cfg := &readline.Config{
Prompt: "demo> ",
HistoryLimit: 100,
DisableAutoSaveHistory: true,
Stdin: io.NopCloser(strings.NewReader("hello readline\n")),
Stdout: &bytes.Buffer{},
FuncFilterInputRune: func(r rune) (rune, bool) {
return r, true
},
}
cfg.SetPainter(&HighlightPainter{})
cfg.SetListener(func(line []rune, pos int, key rune) ([]rune, int, bool) {
return line, pos, true
})
rl, err := readline.NewEx(cfg)
if err != nil {
fmt.Printf("Initialization failed: %v\n", err)
return
}
defer rl.Close()
line, err := rl.Readline()
if err != nil {
fmt.Printf("Readline error: %v\n", err)
return
}
fmt.Printf("Read: %s\n", line)
}
{
"schemaVersion": 1,
"goal": "verify github.com/chzyer/readline.Config in pkg:golang/github.com/chzyer/readline@v1.5.1",
"kind": "HOW",
"packages": [
"pkg:golang/github.com/chzyer/readline@v1.5.1"
],
"symbols": [
"github.com/chzyer/readline.Config"
]
}
package main
import (
"bytes"
"fmt"
"io"
"os"
"strings"
"github.com/chzyer/readline"
)
type customPainter struct {
paintCallCount int
}
func (cp *customPainter) Paint(line []rune, pos int) []rune {
cp.paintCallCount++
return []rune(strings.ToUpper(string(line)))
}
func main() {
if err := runContract(); err != nil {
fmt.Fprintf(os.Stderr, "Contract verification failed: %v\n", err)
os.Exit(1)
}
fmt.Println("All readline.Config contract assertions passed successfully.")
}
func runContract() error {
// Assertion 1: readline.Config.Init establishes default parameters including HistoryLimit and interrupt prompts
cfg := &readline.Config{}
if err := cfg.Init(); err != nil {
return fmt.Errorf("cfg.Init() failed: %w", err)
}
if cfg.HistoryLimit != 500 {
return fmt.Errorf("expected default HistoryLimit=500, got %d", cfg.HistoryLimit)
}
if cfg.InterruptPrompt != "^C" {
return fmt.Errorf("expected default InterruptPrompt='^C', got %q", cfg.InterruptPrompt)
}
if cfg.EOFPrompt != "^D" {
return fmt.Errorf("expected default EOFPrompt='^D', got %q", cfg.EOFPrompt)
}
if cfg.AutoComplete == nil {
return fmt.Errorf("expected non-nil default AutoComplete")
}
// Assertion 2: readline.Config.Clone yields an independent configuration instance preserving settings
baseCfg := &readline.Config{
Prompt: "prompt1> ",
HistoryLimit: 250,
VimMode: true,
}
clonedCfg := baseCfg.Clone()
if clonedCfg.Prompt != "prompt1> " || clonedCfg.HistoryLimit != 250 || !clonedCfg.VimMode {
return fmt.Errorf("cloned config values do not match original")
}
baseCfg.Prompt = "prompt2> "
if clonedCfg.Prompt != "prompt1> " {
return fmt.Errorf("modifying base config affected cloned config prompt")
}
// Assertion 3: readline.Config.SetListener registers custom input event hook callback on configuration
listenerCfg := &readline.Config{}
var listenerInvoked bool
listenerCfg.SetListener(func(line []rune, pos int, key rune) ([]rune, int, bool) {
listenerInvoked = true
return append(line, '+'), pos + 1, true
})
if listenerCfg.Listener == nil {
return fmt.Errorf("expected listenerCfg.Listener to be non-nil after SetListener")
}
newLine, newPos, ok := listenerCfg.Listener.OnChange([]rune("cmd"), 3, 'x')
if !ok || !listenerInvoked || string(newLine) != "cmd+" || newPos != 4 {
return fmt.Errorf("listener execution failed or produced unexpected state")
}
// Assertion 4: readline.Config.SetPainter attaches custom syntax and display painter to configuration
painterCfg := &readline.Config{}
p := &customPainter{}
painterCfg.SetPainter(p)
if painterCfg.Painter != p {
return fmt.Errorf("expected painterCfg.Painter to equal set painter")
}
painted := painterCfg.Painter.Paint([]rune("syntax"), 0)
if string(painted) != "SYNTAX" || p.paintCallCount != 1 {
return fmt.Errorf("custom painter output or call count mismatch")
}
// Assertion 5: readline.Config with FuncFilterInputRune intercepts and transforms input stream runes
var filterStdout bytes.Buffer
filterCfg := &readline.Config{
Prompt: "> ",
Stdin: io.NopCloser(strings.NewReader("a#b#c\n")),
Stdout: &filterStdout,
Stderr: io.Discard,
FuncFilterInputRune: func(r rune) (rune, bool) {
if r == '#' {
return 0, false // drop '#'
}
if r >= 'a' && r <= 'z' {
return r - 32, true // convert to uppercase
}
return r, true
},
}
filterRl, err := readline.NewEx(filterCfg)
if err != nil {
return fmt.Errorf("failed to create readline with FuncFilterInputRune: %w", err)
}
defer filterRl.Close()
filteredLine, err := filterRl.Readline()
if err != nil {
return fmt.Errorf("Readline with FuncFilterInputRune failed: %w", err)
}
if filteredLine != "ABC" {
return fmt.Errorf("expected 'ABC', got %q", filteredLine)
}
// Assertion 6: readline.Config with UniqueEditLine and VimMode configures editor mode and line persistence flags
var flagStdout bytes.Buffer
flagCfg := &readline.Config{
Prompt: "flags> ",
Stdin: io.NopCloser(strings.NewReader("command\n")),
Stdout: &flagStdout,
Stderr: io.Discard,
UniqueEditLine: true,
VimMode: true,
DisableAutoSaveHistory: true,
HistorySearchFold: true,
}
if !flagCfg.UniqueEditLine || !flagCfg.VimMode || !flagCfg.DisableAutoSaveHistory || !flagCfg.HistorySearchFold {
return fmt.Errorf("configuration flags not retained on Config struct")
}
flagRl, err := readline.NewEx(flagCfg)
if err != nil {
return fmt.Errorf("NewEx failed with custom editor and history flags: %w", err)
}
defer flagRl.Close()
flagLine, err := flagRl.Readline()
if err != nil {
return fmt.Errorf("Readline failed with custom flags: %w", err)
}
if flagLine != "command" {
return fmt.Errorf("expected 'command', got %q", flagLine)
}
return nil
}
오리진 시더
익명