Exemple
github.com/imdario/mergo v0.3.12: Merge
Échantillon vérifié pour golang github.com/imdario/mergo v0.3.12: Merge. Le contrat s'est exécuté sur go 1.26 · linux debian/x64 · docker et a réussi.
sha256:c6dcacb2fbc2a23f26edd99bb26733535898be7e07c6b440c8f6bb2a10d07029
Ce réseau offre une seule chose : un échantillon qui compile. Il l'a exécuté dans un bac à sable et conservé le reçu signé. Il ne note rien et ne garantit rien : si le même code compile chez vous, il ne l'a pas mesuré.
Combien de clés de signature distinctes ont déposé un reçu de contrat réussi. Une seule, c'est l'auteur ; plus d'une signifie que quelqu'un d'autre l'a compilé aussi. Une clé est auto-générée sans identité enregistrée derrière, donc on compte des clés, pas des personnes.
MIT-0
Preuves d'exécution
L'environnement déclaré et les exécutions signées sont séparés, pour que vous voyiez exactement ce que cet échantillon a exécuté et où.
- Base de preuve
- Contrat signé réussi
- Reçus de vérification
- 1
- Clés de signature qui l’ont compilé
- 1
Environnement déclaré
linux 24 · ubuntu · glibc 2.39 x64 go
Environnements des exécutions de vérification
| Environnement | Contrat | Étapes | Exécution |
|---|---|---|---|
| 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-04 |
Cas
HOW- Objectif
- verify github.com/imdario/mergo.Merge in pkg:golang/github.com/imdario/mergo@v0.3.12
- Paquets
- Symboles
-
- github.com/imdario/mergo.Merge
- Créé
- 2026-09-04T14:54:01Z
Contrat
- mergo.Merge merges non-zero fields from a source struct into zero-value fields of a destination struct pointer without overwriting existing non-zero fields
- mergo.Merge populates missing keys in a destination map from a source map while preserving existing destination keys
- mergo.Merge returns an error when destination is not a pointer
Fichiers
- PROMPT.md
- csx.json
- go.mod
- go.sum
- main.go
- spec.json
- test/contract.go
Code source
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/imdario/mergo.Merge in pkg:golang/github.com/imdario/mergo@v0.3.12
Kind: HOW
Use EXACTLY these public packages and versions:
- pkg:golang/github.com/imdario/mergo@v0.3.12
Demonstrate these symbols/APIs:
- github.com/imdario/mergo.Merge
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:46b26e05401c05ee19705e9d72671a9306b994a0da80b091df47a5dc71a9cd43","contract":["mergo.Merge merges non-zero fields from a source struct into zero-value fields of a destination struct pointer without overwriting existing non-zero fields","mergo.Merge populates missing keys in a destination map from a source map while preserving existing destination keys","mergo.Merge returns an error when destination is not a pointer"],"goal":"verify github.com/imdario/mergo.Merge in pkg:golang/github.com/imdario/mergo@v0.3.12","kind":"HOW","packages":["pkg:golang/github.com/imdario/mergo@v0.3.12"],"schemaVersion":1,"symbols":["github.com/imdario/mergo.Merge"]},"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/imdario/mergo@v0.3.12"],"schemaVersion":1,"subject":"pkg:golang/github.com/imdario/mergo@v0.3.12","symbols":["github.com/imdario/mergo.Merge"],"verifierAdapter":"golang@1"}
module example.com/sample
go 1.26.6
require github.com/imdario/mergo v0.3.12
github.com/imdario/mergo v0.3.12 h1:b6R2BslTbIEToALKP7LxUvijTsNI9TAe80pLWN2g/HU=
github.com/imdario/mergo v0.3.12/go.mod h1:jmQim1M+e3UYxmgPu/WyfjB3N3VflVyUjjjwH0dnCYA=
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
gopkg.in/yaml.v2 v2.3.0 h1:clyUAQHOM3G0M3f5vQj7LuJrETvjVot3Z5el9nffUtU=
gopkg.in/yaml.v2 v2.3.0/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
package main
import (
"fmt"
"github.com/imdario/mergo"
)
type Config struct {
Host string
Port int
TLS bool
}
func main() {
defaultCfg := Config{
Host: "localhost",
Port: 8080,
TLS: true,
}
userCfg := Config{
Port: 9000,
}
if err := mergo.Merge(&userCfg, defaultCfg); err != nil {
panic(err)
}
fmt.Printf("Merged Config: Host=%s, Port=%d, TLS=%t\n", userCfg.Host, userCfg.Port, userCfg.TLS)
}
{
"schemaVersion": 1,
"goal": "verify github.com/imdario/mergo.Merge in pkg:golang/github.com/imdario/mergo@v0.3.12",
"kind": "HOW",
"packages": [
"pkg:golang/github.com/imdario/mergo@v0.3.12"
],
"symbols": [
"github.com/imdario/mergo.Merge"
]
}
package main
import (
"fmt"
"os"
"github.com/imdario/mergo"
)
type Config struct {
Host string
Port int
TLS bool
}
func main() {
// Assertion 1: mergo.Merge merges non-zero fields from a source struct into zero-value fields of a destination struct pointer without overwriting existing non-zero fields
dest1 := Config{
Port: 9000,
}
src1 := Config{
Host: "localhost",
Port: 8080,
TLS: true,
}
if err := mergo.Merge(&dest1, src1); err != nil {
fmt.Fprintf(os.Stderr, "assertion 1 failed: unexpected error: %v\n", err)
os.Exit(1)
}
if dest1.Host != "localhost" || dest1.Port != 9000 || dest1.TLS != true {
fmt.Fprintf(os.Stderr, "assertion 1 failed: expected Host=localhost, Port=9000, TLS=true; got Host=%s, Port=%d, TLS=%t\n", dest1.Host, dest1.Port, dest1.TLS)
os.Exit(1)
}
// Assertion 2: mergo.Merge populates missing keys in a destination map from a source map while preserving existing destination keys
destMap := map[string]string{
"env": "production",
"tier": "backend",
}
srcMap := map[string]string{
"tier": "frontend",
"region": "us-west",
}
if err := mergo.Merge(&destMap, srcMap); err != nil {
fmt.Fprintf(os.Stderr, "assertion 2 failed: unexpected error: %v\n", err)
os.Exit(1)
}
if destMap["env"] != "production" || destMap["tier"] != "backend" || destMap["region"] != "us-west" {
fmt.Fprintf(os.Stderr, "assertion 2 failed: map content mismatch: %v\n", destMap)
os.Exit(1)
}
// Assertion 3: mergo.Merge returns an error when destination is not a pointer
destNonPtr := Config{}
srcNonPtr := Config{Host: "example.com"}
if err := mergo.Merge(destNonPtr, srcNonPtr); err == nil {
fmt.Fprintf(os.Stderr, "assertion 3 failed: expected error when dst is not a pointer, got nil\n")
os.Exit(1)
}
fmt.Println("All contract assertions passed.")
}
Seeder d'origine
anonyme