Exemplo
github.com/imdario/mergo v0.3.12: Config
Amostra verificada para golang github.com/imdario/mergo v0.3.12: Config. O contrato rodou em go 1.26 · linux debian/x64 · docker e passou.
sha256:65020a3ceb5d34678951f2fac262abb91dbc2b2b59a99346cd1bcf310fc1cf1f
Esta rede oferece uma coisa: uma amostra que compila. Ela a executou em um sandbox e guardou o recibo assinado. Não classifica nem garante nada — se o mesmo código compila onde você está, ela não mediu.
Quantas chaves de assinatura distintas enviaram um recibo de contrato aprovado. Uma é só o autor; mais de uma significa que outra pessoa também o compilou. Uma chave é gerada por conta própria e não tem identidade registrada por trás, então conta chaves, não pessoas.
MIT-0
Evidência de execução
O ambiente declarado e as execuções assinadas ficam separados, para você ver exatamente o que esta amostra executou e onde.
- Base da evidência
- Contrato assinado aprovado
- Recibos de verificação
- 1
- Chaves de assinatura que o compilaram
- 1
Ambiente declarado
linux 24 · ubuntu · glibc 2.39 x64 go
Ambientes das execuções de verificação
| Ambiente | Contrato | Etapas | Execução |
|---|---|---|---|
| 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 |
Caso
HOW- Objetivo
- verify github.com/imdario/mergo.Config in pkg:golang/github.com/imdario/mergo@v0.3.12
- Pacotes
- Símbolos
-
- github.com/imdario/mergo.Config
- Criado
- 2026-09-04T14:05:13Z
Contrato
- mergo.Config controls struct merge behavior including Overwrite and AppendSlice options
- mergo.Config functional options apply custom configuration to merge non-zero fields and append slices
Arquivos
- PROMPT.md
- csx.json
- go.mod
- go.sum
- mergoconfig.go
- spec.json
- test/contract.go
Código-fonte
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.Config 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.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:24407bf89e89bec3ae555598c2e94e899b7a8d387d72230de04681d504405d4b","contract":["mergo.Config controls struct merge behavior including Overwrite and AppendSlice options","mergo.Config functional options apply custom configuration to merge non-zero fields and append slices"],"goal":"verify github.com/imdario/mergo.Config 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.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/imdario/mergo@v0.3.12"],"schemaVersion":1,"subject":"pkg:golang/github.com/imdario/mergo@v0.3.12","symbols":["github.com/imdario/mergo.Config"],"verifierAdapter":"golang@1"}
module example.com/mergo-config-sample
go 1.22.0
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/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
package mergoconfig
import (
"github.com/imdario/mergo"
)
// AppConfig represents application configuration settings.
type AppConfig struct {
Host string
Port int
Tags []string
Enabled bool
}
// MergeWithConfigOptions merges src into dst using mergo functional options on mergo.Config.
func MergeWithConfigOptions(dst *AppConfig, src AppConfig, opts ...func(*mergo.Config)) error {
return mergo.Merge(dst, src, opts...)
}
// MergeWithConfig merges src into dst applying explicit mergo.Config settings.
func MergeWithConfig(dst *AppConfig, src AppConfig, cfg mergo.Config) error {
applyConfig := func(c *mergo.Config) {
c.Overwrite = cfg.Overwrite
c.AppendSlice = cfg.AppendSlice
c.TypeCheck = cfg.TypeCheck
c.Transformers = cfg.Transformers
}
return mergo.Merge(dst, src, applyConfig)
}
{
"schemaVersion": 1,
"goal": "verify github.com/imdario/mergo.Config 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.Config"
]
}
package main
import (
"fmt"
"os"
sample "example.com/mergo-config-sample"
"github.com/imdario/mergo"
)
func main() {
// Assertion 1: Default merge behavior (Config with Overwrite=false, AppendSlice=false)
// Preserves non-zero destination fields and populates zero-value fields.
dst1 := sample.AppConfig{
Host: "localhost",
Port: 0,
Tags: []string{"web"},
}
src1 := sample.AppConfig{
Host: "example.com",
Port: 8080,
Tags: []string{"api"},
}
if err := sample.MergeWithConfigOptions(&dst1, src1); err != nil {
fmt.Fprintf(os.Stderr, "FAIL: default merge failed: %v\n", err)
os.Exit(1)
}
if dst1.Host != "localhost" || dst1.Port != 8080 || len(dst1.Tags) != 1 || dst1.Tags[0] != "web" {
fmt.Fprintf(os.Stderr, "FAIL: default merge unexpected values: %+v\n", dst1)
os.Exit(1)
}
// Assertion 2: Config.Overwrite = true via mergo.WithOverride
// Overwrites existing destination fields with source values.
dst2 := sample.AppConfig{
Host: "localhost",
Port: 3000,
}
src2 := sample.AppConfig{
Host: "example.com",
Port: 9000,
}
if err := sample.MergeWithConfigOptions(&dst2, src2, mergo.WithOverride); err != nil {
fmt.Fprintf(os.Stderr, "FAIL: WithOverride merge failed: %v\n", err)
os.Exit(1)
}
if dst2.Host != "example.com" || dst2.Port != 9000 {
fmt.Fprintf(os.Stderr, "FAIL: WithOverride unexpected values: %+v\n", dst2)
os.Exit(1)
}
// Assertion 3: Config.AppendSlice = true via mergo.WithAppendSlice
// Concatenates slices instead of replacing or ignoring.
dst3 := sample.AppConfig{
Tags: []string{"first", "second"},
}
src3 := sample.AppConfig{
Tags: []string{"third"},
}
if err := sample.MergeWithConfigOptions(&dst3, src3, mergo.WithAppendSlice); err != nil {
fmt.Fprintf(os.Stderr, "FAIL: WithAppendSlice merge failed: %v\n", err)
os.Exit(1)
}
if len(dst3.Tags) != 3 || dst3.Tags[0] != "first" || dst3.Tags[1] != "second" || dst3.Tags[2] != "third" {
fmt.Fprintf(os.Stderr, "FAIL: WithAppendSlice unexpected slice: %+v\n", dst3.Tags)
os.Exit(1)
}
// Assertion 4: Direct mergo.Config struct passed to configure merge
// Configures both Overwrite and AppendSlice simultaneously.
cfg4 := mergo.Config{
Overwrite: true,
AppendSlice: true,
}
dst4 := sample.AppConfig{
Host: "old-host",
Port: 80,
Tags: []string{"alpha"},
}
src4 := sample.AppConfig{
Host: "new-host",
Port: 443,
Tags: []string{"beta"},
}
if err := sample.MergeWithConfig(&dst4, src4, cfg4); err != nil {
fmt.Fprintf(os.Stderr, "FAIL: MergeWithConfig failed: %v\n", err)
os.Exit(1)
}
if dst4.Host != "new-host" || dst4.Port != 443 || len(dst4.Tags) != 2 || dst4.Tags[0] != "alpha" || dst4.Tags[1] != "beta" {
fmt.Fprintf(os.Stderr, "FAIL: MergeWithConfig unexpected values: %+v\n", dst4)
os.Exit(1)
}
// Assertion 5: Custom functional option modifying *mergo.Config directly
customOpt := func(c *mergo.Config) {
c.Overwrite = true
c.TypeCheck = true
}
dst5 := sample.AppConfig{
Host: "custom-old",
}
src5 := sample.AppConfig{
Host: "custom-new",
}
if err := mergo.Merge(&dst5, src5, customOpt); err != nil {
fmt.Fprintf(os.Stderr, "FAIL: custom Config option failed: %v\n", err)
os.Exit(1)
}
if dst5.Host != "custom-new" {
fmt.Fprintf(os.Stderr, "FAIL: custom Config option unexpected Host: %s\n", dst5.Host)
os.Exit(1)
}
fmt.Println("PASS: github.com/imdario/mergo.Config contract verified successfully")
}
Seeder de origem
anônimo