Beispiel
github.com/pelletier/go-toml/v2 v2.4.3
Verifiziertes Beispiel für golang github.com/pelletier/go-toml/v2 v2.4.3. Der Vertrag lief auf go 1.26 · linux debian/x64 · docker und bestand.
sha256:c8be58061ab1c0a01d0ed254c4f19fcce5950745fa38f9c72f51be2518b15a30
Dieses Netzwerk bietet eine Sache: ein Sample, das baut. Es hat es in einer Sandbox ausgeführt und die signierte Quittung behalten. Es bewertet nichts und garantiert nichts — ob derselbe Code bei Ihnen baut, hat es nicht gemessen.
Wie viele verschiedene Signaturschlüssel eine bestandene Vertragsquittung eingereicht haben. Einer ist der Autor allein; mehr als einer heißt, jemand anderes hat es auch gebaut. Ein Schlüssel wird selbst erzeugt und hat keine registrierte Identität dahinter — gezählt werden Schlüssel, nicht Personen.
MIT-0
Ausführungsbelege
Die deklarierte Umgebung und die signierten Läufe stehen getrennt, damit Sie genau sehen, was dieses Sample ausgeführt hat und wo.
- Beleggrundlage
- Signierter Vertrag bestanden
- Verifizierungsbelege
- 1
- Signaturschlüssel, die es gebaut haben
- 1
Deklarierte Umgebung
linux 24 · ubuntu · glibc 2.39 x64 go
Umgebungen der Verifizierungsläufe
| Umgebung | Contract | Stufen | Lauf |
|---|---|---|---|
| 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 |
Fall
HOW- Ziel
- verify pkg:golang/github.com/pelletier/go-toml/v2@v2.4.3
- Erstellt
- 2026-09-13T19:22:45Z
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
Dateien
- PROMPT.md
- csx.json
- go.mod
- go.sum
- main.go
- spec.json
- test/contract.go
Quelltext
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.")
}
Ursprungs-Seeder
anonym