샘플
github.com/pelletier/go-toml/v2 v2.4.3
검증된 샘플 — golang github.com/pelletier/go-toml/v2 v2.4.3. go 1.26 · linux debian/x64 · docker에서 contract를 실행해 통과했습니다: toml.Marshal serializes structs and maps…
sha256:c8be58061ab1c0a01d0ed254c4f19fcce5950745fa38f9c72f51be2518b15a30
이 네트워크가 제공하는 것은 하나입니다. 빌드되는 샘플. 샌드박스에서 돌리고 서명된 영수증을 보관합니다. 등급을 매기지 않고 무엇도 보증하지 않습니다 — 같은 코드가 당신 환경에서 빌드되는지는 측정한 적이 없습니다.
통과한 계약 영수증을 낸 서로 다른 서명 키의 수입니다. 하나면 작성자 혼자이고, 둘 이상이면 다른 사람도 빌드했다는 뜻입니다. 키는 스스로 만드는 것이고 뒤에 등록된 신원이 없으므로, 세는 것은 사람이 아니라 키입니다.
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-13 |
케이스
HOW- 목표
- verify pkg:golang/github.com/pelletier/go-toml/v2@v2.4.3
- 생성일
- 2026-09-13T19:22:45Z
컨트랙트
- toml.Marshal serializes structs and maps into valid TOML bytes
- toml.Unmarshal deserializes TOML bytes into target structs with matching fields
- toml.NewDecoder and toml.NewEncoder stream TOML content via io.Reader and io.Writer
- toml.Unmarshal returns an error when parsing malformed TOML syntax
파일
- 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/github.com/pelletier/go-toml/v2@v2.4.3
Kind: HOW
Use EXACTLY these public packages and versions:
- pkg:golang/github.com/pelletier/go-toml/v2@v2.4.3
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:009c7c94a3d384dc640b97d176115f670294dbe1fb76f70686bd905d2842694a","contract":["toml.Marshal serializes structs and maps into valid TOML bytes","toml.Unmarshal deserializes TOML bytes into target structs with matching fields","toml.NewDecoder and toml.NewEncoder stream TOML content via io.Reader and io.Writer","toml.Unmarshal returns an error when parsing malformed TOML syntax"],"goal":"verify pkg:golang/github.com/pelletier/go-toml/v2@v2.4.3","kind":"HOW","packages":["pkg:golang/github.com/pelletier/go-toml/v2@v2.4.3"],"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/github.com/pelletier/go-toml/v2@v2.4.3"],"schemaVersion":1,"subject":"pkg:golang/github.com/pelletier/go-toml/v2@v2.4.3","verifierAdapter":"golang@1"}
module sample
go 1.26.6
require github.com/pelletier/go-toml/v2 v2.4.3
github.com/pelletier/go-toml/v2 v2.4.3 h1:GTRvJQutkOSftxIFD5xw9aepkYNuPWmVJpffdDPYVpY=
github.com/pelletier/go-toml/v2 v2.4.3/go.mod h1:2gIqNv+qfxSVS7cM2xJQKtLSTLUE9V8t9Stt+h56mCY=
package main
import (
"fmt"
"os"
"github.com/pelletier/go-toml/v2"
)
type Config struct {
Title string `toml:"title"`
Version string `toml:"version"`
Ports []int `toml:"ports"`
Server Server `toml:"server"`
}
type Server struct {
Host string `toml:"host"`
Port int `toml:"port"`
}
func main() {
doc := `
title = "Sample Application"
version = "1.0.0"
ports = [8080, 8081]
[server]
host = "127.0.0.1"
port = 8080
`
var cfg Config
if err := toml.Unmarshal([]byte(doc), &cfg); err != nil {
fmt.Fprintf(os.Stderr, "failed to unmarshal: %v\n", err)
os.Exit(1)
}
fmt.Printf("Parsed config title: %s\n", cfg.Title)
fmt.Printf("Server host: %s:%d\n", cfg.Server.Host, cfg.Server.Port)
out, err := toml.Marshal(cfg)
if err != nil {
fmt.Fprintf(os.Stderr, "failed to marshal: %v\n", err)
os.Exit(1)
}
fmt.Printf("Marshaled output:\n%s\n", string(out))
}
{
"schemaVersion": 1,
"goal": "verify pkg:golang/github.com/pelletier/go-toml/v2@v2.4.3",
"kind": "HOW",
"packages": [
"pkg:golang/github.com/pelletier/go-toml/v2@v2.4.3"
]
}
package main
import (
"bytes"
"fmt"
"os"
"strings"
"github.com/pelletier/go-toml/v2"
)
type DatabaseConfig struct {
Enabled bool `toml:"enabled"`
Host string `toml:"host"`
Port int `toml:"port"`
}
type AppConfig struct {
Name string `toml:"name"`
Database DatabaseConfig `toml:"database"`
Tags []string `toml:"tags"`
}
func main() {
// Assertion 1: toml.Marshal serializes structs and maps into valid TOML bytes
{
cfg := AppConfig{
Name: "test-app",
Database: DatabaseConfig{
Enabled: true,
Host: "localhost",
Port: 5432,
},
Tags: []string{"backend", "v2"},
}
data, err := toml.Marshal(cfg)
if err != nil {
fmt.Fprintf(os.Stderr, "assertion 1 failed: unexpected marshal error: %v\n", err)
os.Exit(1)
}
text := string(data)
if !strings.Contains(text, "name = 'test-app'") && !strings.Contains(text, `name = "test-app"`) {
fmt.Fprintf(os.Stderr, "assertion 1 failed: name field missing or incorrect in %s\n", text)
os.Exit(1)
}
if !strings.Contains(text, "[database]") {
fmt.Fprintf(os.Stderr, "assertion 1 failed: [database] section missing in %s\n", text)
os.Exit(1)
}
}
// Assertion 2: toml.Unmarshal deserializes TOML bytes into target structs with matching fields
{
raw := `
name = "demo-service"
tags = ["alpha", "beta"]
[database]
enabled = true
host = "127.0.0.1"
port = 3306
`
var parsed AppConfig
if err := toml.Unmarshal([]byte(raw), &parsed); err != nil {
fmt.Fprintf(os.Stderr, "assertion 2 failed: unexpected unmarshal error: %v\n", err)
os.Exit(1)
}
if parsed.Name != "demo-service" {
fmt.Fprintf(os.Stderr, "assertion 2 failed: expected name 'demo-service', got '%s'\n", parsed.Name)
os.Exit(1)
}
if !parsed.Database.Enabled || parsed.Database.Host != "127.0.0.1" || parsed.Database.Port != 3306 {
fmt.Fprintf(os.Stderr, "assertion 2 failed: database mismatch: %+v\n", parsed.Database)
os.Exit(1)
}
if len(parsed.Tags) != 2 || parsed.Tags[0] != "alpha" || parsed.Tags[1] != "beta" {
fmt.Fprintf(os.Stderr, "assertion 2 failed: tags mismatch: %+v\n", parsed.Tags)
os.Exit(1)
}
}
// Assertion 3: toml.NewDecoder and toml.NewEncoder stream TOML content via io.Reader and io.Writer
{
source := `
name = "streamed-app"
[database]
enabled = false
host = "remotehost"
port = 9000
`
var cfg AppConfig
decoder := toml.NewDecoder(strings.NewReader(source))
if err := decoder.Decode(&cfg); err != nil {
fmt.Fprintf(os.Stderr, "assertion 3 failed: decode error: %v\n", err)
os.Exit(1)
}
if cfg.Name != "streamed-app" || cfg.Database.Port != 9000 {
fmt.Fprintf(os.Stderr, "assertion 3 failed: decoded config mismatch: %+v\n", cfg)
os.Exit(1)
}
var buf bytes.Buffer
encoder := toml.NewEncoder(&buf)
if err := encoder.Encode(cfg); err != nil {
fmt.Fprintf(os.Stderr, "assertion 3 failed: encode error: %v\n", err)
os.Exit(1)
}
if buf.Len() == 0 || !strings.Contains(buf.String(), "streamed-app") {
fmt.Fprintf(os.Stderr, "assertion 3 failed: encoded buffer invalid: %s\n", buf.String())
os.Exit(1)
}
}
// Assertion 4: toml.Unmarshal returns an error when parsing malformed TOML syntax
{
malformed := `
name = "unclosed-string
invalid toml line here = = =
`
var target map[string]any
err := toml.Unmarshal([]byte(malformed), &target)
if err == nil {
fmt.Fprintf(os.Stderr, "assertion 4 failed: expected error for malformed TOML, got nil\n")
os.Exit(1)
}
}
fmt.Println("All contract assertions passed successfully.")
}
오리진 시더
익명