Beispiel
github.com/spf13/viper v1.3.2
Verifiziertes Beispiel für golang github.com/spf13/viper v1.3.2. Der Vertrag lief auf go 1.26 · linux debian/x64 · docker und bestand.
sha256:901c0830e9411594e62338032762fbe7a8d1d1b1b106f1d9dde0cbc40426a9a6
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-10-27 |
Fall
HOW- Ziel
- verify pkg:golang/github.com/spf13/viper@v1.3.2
- Erstellt
- 2026-10-27T22:14:04Z
Contract
- viper.New creates an isolated configuration instance where SetDefault provides fallback values when no higher-precedence source is set
- ReadConfig with SetConfigType("json") parses in-memory JSON configuration that overrides defaults while preserving unset default keys
- Explicit Set overrides values loaded via ReadConfig and SetDefault in hierarchical precedence order
- Unmarshal decodes the resolved configuration hierarchy into a Go struct
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/spf13/viper@v1.3.2
Kind: HOW
Use EXACTLY these public packages and versions:
- pkg:golang/github.com/spf13/viper@v1.3.2
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:7ef1725760049613f1642c34d351e010a379be8ed0fac4a27619a968c134c48c","contract":["viper.New creates an isolated configuration instance where SetDefault provides fallback values when no higher-precedence source is set","ReadConfig with SetConfigType(\"json\") parses in-memory JSON configuration that overrides defaults while preserving unset default keys","Explicit Set overrides values loaded via ReadConfig and SetDefault in hierarchical precedence order","Unmarshal decodes the resolved configuration hierarchy into a Go struct"],"goal":"verify pkg:golang/github.com/spf13/viper@v1.3.2","kind":"HOW","packages":["pkg:golang/github.com/spf13/viper@v1.3.2"],"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/spf13/viper@v1.3.2"],"schemaVersion":1,"subject":"pkg:golang/github.com/spf13/viper@v1.3.2","verifierAdapter":"golang@1"}
module example.com/sample
go 1.26.6
require github.com/spf13/viper v1.3.2
require (
github.com/BurntSushi/toml v1.6.0 // indirect
github.com/fsnotify/fsnotify v1.4.7 // indirect
github.com/hashicorp/hcl v1.0.0 // indirect
github.com/magiconair/properties v1.8.0 // indirect
github.com/mitchellh/mapstructure v1.1.2 // indirect
github.com/pelletier/go-toml v1.2.0 // indirect
github.com/spf13/afero v1.1.2 // indirect
github.com/spf13/cast v1.3.0 // indirect
github.com/spf13/jwalterweatherman v1.0.0 // indirect
github.com/spf13/pflag v1.0.3 // indirect
golang.org/x/sys v0.0.0-20181205085412-a5c9d58dba9a // indirect
golang.org/x/text v0.3.0 // indirect
gopkg.in/yaml.v2 v2.2.2 // indirect
)
github.com/BurntSushi/toml v1.6.0 h1:dRaEfpa2VI55EwlIW72hMRHdWouJeRF7TPYhI+AUQjk=
github.com/BurntSushi/toml v1.6.0/go.mod h1:ukJfTF/6rtPPRCnwkur4qwRxa8vTRFBF0uk2lLoLwho=
github.com/armon/consul-api v0.0.0-20180202201655-eb2c6b5be1b6/go.mod h1:grANhF5doyWs3UAsr3K4I6qtAmlQcZDesFNEHPZAzj8=
github.com/coreos/etcd v3.3.10+incompatible/go.mod h1:uF7uidLiAD3TWHmW31ZFd/JWoc32PjwdhPthX9715RE=
github.com/coreos/go-etcd v2.0.0+incompatible/go.mod h1:Jez6KQU2B/sWsbdaef3ED8NzMklzPG4d5KIOhIy30Tk=
github.com/coreos/go-semver v0.2.0/go.mod h1:nnelYz7RCh+5ahJtPPxZlU+153eP4D4r3EedlOD2RNk=
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/fsnotify/fsnotify v1.4.7 h1:IXs+QLmnXW2CcXuY+8Mzv/fWEsPGWxqefPtCP5CnV9I=
github.com/fsnotify/fsnotify v1.4.7/go.mod h1:jwhsz4b93w/PPRr/qN1Yymfu8t87LnFCMoQvtojpjFo=
github.com/hashicorp/hcl v1.0.0 h1:0Anlzjpi4vEasTeNFn2mLJgTSwt0+6sfsiTG8qcWGx4=
github.com/hashicorp/hcl v1.0.0/go.mod h1:E5yfLk+7swimpb2L/Alb/PJmXilQ/rhwaUYs4T20WEQ=
github.com/magiconair/properties v1.8.0 h1:LLgXmsheXeRoUOBOjtwPQCWIYqM/LU1ayDtDePerRcY=
github.com/magiconair/properties v1.8.0/go.mod h1:PppfXfuXeibc/6YijjN8zIbojt8czPbwD3XqdrwzmxQ=
github.com/mitchellh/mapstructure v1.1.2 h1:fmNYVwqnSfB9mZU6OS2O6GsXM+wcskZDuKQzvN1EDeE=
github.com/mitchellh/mapstructure v1.1.2/go.mod h1:FVVH3fgwuzCH5S8UJGiWEs2h04kUh9fWfEaFds41c1Y=
github.com/pelletier/go-toml v1.2.0 h1:T5zMGML61Wp+FlcbWjRDT7yAxhJNAiPPLOFECq181zc=
github.com/pelletier/go-toml v1.2.0/go.mod h1:5z9KED0ma1S8pY6P1sdut58dfprrGBbd/94hg7ilaic=
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
github.com/spf13/afero v1.1.2 h1:m8/z1t7/fwjysjQRYbP0RD+bUIF/8tJwPdEZsI83ACI=
github.com/spf13/afero v1.1.2/go.mod h1:j4pytiNVoe2o6bmDsKpLACNPDBIoEAkihy7loJ1B0CQ=
github.com/spf13/cast v1.3.0 h1:oget//CVOEoFewqQxwr0Ej5yjygnqGkvggSE/gB35Q8=
github.com/spf13/cast v1.3.0/go.mod h1:Qx5cxh0v+4UWYiBimWS+eyWzqEqokIECu5etghLkUJE=
github.com/spf13/jwalterweatherman v1.0.0 h1:XHEdyB+EcvlqZamSM4ZOMGlc93t6AcsBEu9Gc1vn7yk=
github.com/spf13/jwalterweatherman v1.0.0/go.mod h1:cQK4TGJAtQXfYWX+Ddv3mKDzgVb68N+wFjFa4jdeBTo=
github.com/spf13/pflag v1.0.3 h1:zPAT6CGy6wXeQ7NtTnaTerfKOsV6V6F8agHXFiazDkg=
github.com/spf13/pflag v1.0.3/go.mod h1:DYY7MBk1bdzusC3SYhjObp+wFpr4gzcvqqNjLnInEg4=
github.com/spf13/viper v1.3.2 h1:VUFqw5KcqRf7i70GOzW7N+Q7+gxVBkSSqiXB12+JQ4M=
github.com/spf13/viper v1.3.2/go.mod h1:ZiWeW+zYFKm7srdB9IoDzzZXaJaI5eL9QjNiN/DMA2s=
github.com/stretchr/testify v1.2.2 h1:bSDNvY7ZPG5RlJ8otE/7V6gMiyenm9RtJ7IUVIAoJ1w=
github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs=
github.com/ugorji/go/codec v0.0.0-20181204163529-d75b2dcb6bc8/go.mod h1:VFNgLljTbGfSG7qAOspJ7OScBnGdDN/yBr0sguwnwf0=
github.com/xordataexchange/crypt v0.0.3-0.20170626215501-b2862e3d0a77/go.mod h1:aYKd//L2LvnjZzWKhF00oedf4jCCReLcmhLdhm1A27Q=
golang.org/x/crypto v0.0.0-20181203042331-505ab145d0a9/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4=
golang.org/x/sys v0.0.0-20181205085412-a5c9d58dba9a h1:1n5lsVfiQW3yfsRGu98756EH1YthsFqr/5mxHduZW2A=
golang.org/x/sys v0.0.0-20181205085412-a5c9d58dba9a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
golang.org/x/text v0.3.0 h1:g61tztE5qeGQ89tm6NTjjM9VPIm088od1l6aSorWRWg=
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM=
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
gopkg.in/yaml.v2 v2.2.2 h1:ZCJp+EgiOT7lHqUV2J862kp8Qj64Jo6az82+3Td9dZw=
gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
package main
import (
"fmt"
"strings"
"github.com/spf13/viper"
)
type ServerConfig struct {
Host string `mapstructure:"host"`
Port int `mapstructure:"port"`
TLS bool `mapstructure:"tls"`
}
func main() {
v := viper.New()
v.SetDefault("host", "localhost")
v.SetDefault("port", 8080)
v.SetDefault("tls", false)
v.SetConfigType("json")
err := v.ReadConfig(strings.NewReader(`{"port": 9000, "tls": true}`))
if err != nil {
panic(err)
}
v.Set("host", "example.com")
var cfg ServerConfig
if err := v.Unmarshal(&cfg); err != nil {
panic(err)
}
fmt.Printf("host=%s port=%d tls=%t\n", cfg.Host, cfg.Port, cfg.TLS)
}
{
"schemaVersion": 1,
"goal": "verify pkg:golang/github.com/spf13/viper@v1.3.2",
"kind": "HOW",
"packages": [
"pkg:golang/github.com/spf13/viper@v1.3.2"
]
}
package main
import (
"fmt"
"os"
"strings"
"github.com/spf13/viper"
)
type AppConfig struct {
Host string `mapstructure:"host"`
Port int `mapstructure:"port"`
Enabled bool `mapstructure:"enabled"`
}
func main() {
v := viper.New()
// Assertion 1: SetDefault provides fallback values when no higher-precedence source is set
v.SetDefault("host", "localhost")
v.SetDefault("port", 8080)
v.SetDefault("enabled", false)
if got := v.GetString("host"); got != "localhost" {
fmt.Fprintf(os.Stderr, "assertion 1 failed: expected default host %q, got %q\n", "localhost", got)
os.Exit(1)
}
if got := v.GetInt("port"); got != 8080 {
fmt.Fprintf(os.Stderr, "assertion 1 failed: expected default port 8080, got %d\n", got)
os.Exit(1)
}
// Assertion 2: ReadConfig with SetConfigType("json") overrides defaults while preserving unset default keys
v.SetConfigType("json")
if err := v.ReadConfig(strings.NewReader(`{"port": 9000, "enabled": true}`)); err != nil {
fmt.Fprintf(os.Stderr, "assertion 2 failed: ReadConfig returned error: %v\n", err)
os.Exit(1)
}
if got := v.GetInt("port"); got != 9000 {
fmt.Fprintf(os.Stderr, "assertion 2 failed: expected config port 9000, got %d\n", got)
os.Exit(1)
}
if got := v.GetBool("enabled"); !got {
fmt.Fprintf(os.Stderr, "assertion 2 failed: expected config enabled=true, got %t\n", got)
os.Exit(1)
}
if got := v.GetString("host"); got != "localhost" {
fmt.Fprintf(os.Stderr, "assertion 2 failed: expected preserved default host %q, got %q\n", "localhost", got)
os.Exit(1)
}
// Assertion 3: Explicit Set overrides values loaded via ReadConfig and SetDefault
v.Set("port", 9090)
v.Set("host", "example.com")
if got := v.GetInt("port"); got != 9090 {
fmt.Fprintf(os.Stderr, "assertion 3 failed: expected Set port 9090, got %d\n", got)
os.Exit(1)
}
if got := v.GetString("host"); got != "example.com" {
fmt.Fprintf(os.Stderr, "assertion 3 failed: expected Set host %q, got %q\n", "example.com", got)
os.Exit(1)
}
// Assertion 4: Unmarshal decodes the resolved configuration hierarchy into a Go struct
var cfg AppConfig
if err := v.Unmarshal(&cfg); err != nil {
fmt.Fprintf(os.Stderr, "assertion 4 failed: Unmarshal returned error: %v\n", err)
os.Exit(1)
}
if cfg.Host != "example.com" || cfg.Port != 9090 || !cfg.Enabled {
fmt.Fprintf(os.Stderr, "assertion 4 failed: unexpected struct %+v\n", cfg)
os.Exit(1)
}
fmt.Println("All contract assertions passed.")
}
Ursprungs-Seeder
anonym