Exemplo
github.com/imdario/mergo v0.3.8: Merge
Amostra verificada para golang github.com/imdario/mergo v0.3.8: Merge. O contrato rodou em go 1.26 · linux alpine/x64 · docker e passou.
sha256:138ab318ae6127bb59d13da0cc6884906c5e01bc9334574e400c294803b34e19
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 alpine/x64 · docker ed25519:c1973797be207ac4 | PASS | compile:SKIPPED · contract:PASS · load:PASS · resolve:PASS CONTAINER_RUN · golang@1golang:1.26-alpine@sha256:28d89ee9cc0f… |
2026-08-28 |
Caso
HOW- Objetivo
- verify pkg:golang/github.com/imdario/mergo@v0.3.8
- Pacotes
- Símbolos
-
- mergo.Merge
- Criado
- 2026-08-28T00:48:03Z
Contrato
- mergo.Merge merges non-zero fields from a source struct into zero-value fields of a destination struct without overwriting non-zero destination fields.
- mergo.Merge with mergo.WithOverride overwrites existing non-zero destination fields with source values.
- mergo.Merge with mergo.WithAppendSlice appends source slice elements to destination slice elements.
- mergo.Merge returns an error when destination or source argument is nil.
Arquivos
- PROMPT.md
- csx.json
- go.mod
- go.sum
- main.go
- spec.json
- test/contract_test.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 pkg:golang/github.com/imdario/mergo@v0.3.8
Kind: HOW
Use EXACTLY these public packages and versions:
- pkg:golang/github.com/imdario/mergo@v0.3.8
Demonstrate these symbols/APIs:
- 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:cf0fffe452267b3fbff232836f9cdcf060d84b0b07a3df66339306001f91e2ec","contract":["mergo.Merge merges non-zero fields from a source struct into zero-value fields of a destination struct without overwriting non-zero destination fields.","mergo.Merge with mergo.WithOverride overwrites existing non-zero destination fields with source values.","mergo.Merge with mergo.WithAppendSlice appends source slice elements to destination slice elements.","mergo.Merge returns an error when destination or source argument is nil."],"goal":"verify pkg:golang/github.com/imdario/mergo@v0.3.8","kind":"HOW","packages":["pkg:golang/github.com/imdario/mergo@v0.3.8"],"schemaVersion":1,"symbols":["mergo.Merge"]},"contractCommand":["go","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.8"],"schemaVersion":1,"subject":"pkg:golang/github.com/imdario/mergo@v0.3.8","symbols":["mergo.Merge"],"verifierAdapter":"golang@1"}
module example.com/mergomerge
go 1.22
require github.com/imdario/mergo v0.3.8
require (
github.com/stretchr/testify v1.12.1 // indirect
gopkg.in/yaml.v2 v2.4.0 // indirect
)
github.com/imdario/mergo v0.3.8 h1:CGgOkSJeqMRmt0D9XLWExdT4m4F1vd3FV3VPt+0VxkQ=
github.com/imdario/mergo v0.3.8/go.mod h1:2EnlNZ0deacrJVfApfmtdGgDfMuh/nq6Ok1EcJh5FfA=
github.com/stretchr/testify v1.12.1 h1:EuwCh5fleGS7H32xRwO3wRGT7DxrDhLAT6FF8MpWDWE=
github.com/stretchr/testify v1.12.1/go.mod h1:MDEgiDPPsNp5cuIrHPPCyornHKgEVbtFUmoNlxoYthg=
go.yaml.in/yaml/v3 v3.0.5 h1:N6y/pJk8buWs9NY5ERU2HSMfm+IuD/OtfdAnq6kESPw=
go.yaml.in/yaml/v3 v3.0.5/go.mod h1:HVTZu1O7/Vkt2N+BFy8Zza+lnLsABggaTM2ZpNIGuKg=
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
gopkg.in/yaml.v2 v2.4.0 h1:D8xgwECY7CYvx+Y2n4sBz93Jn9JRvxdiyyo8CTfuKaY=
gopkg.in/yaml.v2 v2.4.0/go.mod h1:RDklbk79AGWmwhnvt/jBztapEOGDOx6ZbXqjP6csGnQ=
package main
import (
"fmt"
"github.com/imdario/mergo"
)
type Config struct {
Host string
Port int
Timeout int
Tags []string
}
func main() {
defaultCfg := Config{
Host: "localhost",
Port: 8080,
Timeout: 30,
Tags: []string{"default"},
}
userCfg := Config{
Port: 9000,
}
if err := mergo.Merge(&userCfg, defaultCfg); err != nil {
panic(err)
}
fmt.Printf("Host: %s, Port: %d, Timeout: %d, Tags: %v\n", userCfg.Host, userCfg.Port, userCfg.Timeout, userCfg.Tags)
}
{
"schemaVersion": 1,
"goal": "verify pkg:golang/github.com/imdario/mergo@v0.3.8",
"kind": "HOW",
"packages": [
"pkg:golang/github.com/imdario/mergo@v0.3.8"
],
"symbols": [
"mergo.Merge"
]
}
package test
import (
"reflect"
"testing"
"github.com/imdario/mergo"
)
type ServerConfig struct {
Host string
Port int
Timeout int
Tags []string
}
func TestMergeDefaultWithoutOverwrite(t *testing.T) {
dst := ServerConfig{
Port: 9000,
}
src := ServerConfig{
Host: "localhost",
Port: 8080,
Timeout: 30,
Tags: []string{"web", "api"},
}
if err := mergo.Merge(&dst, src); err != nil {
t.Fatalf("mergo.Merge failed: %v", err)
}
if dst.Host != "localhost" {
t.Errorf("expected Host 'localhost', got %q", dst.Host)
}
if dst.Port != 9000 {
t.Errorf("expected Port 9000 (preserved), got %d", dst.Port)
}
if dst.Timeout != 30 {
t.Errorf("expected Timeout 30, got %d", dst.Timeout)
}
if !reflect.DeepEqual(dst.Tags, []string{"web", "api"}) {
t.Errorf("expected Tags [web api], got %v", dst.Tags)
}
}
func TestMergeWithOverride(t *testing.T) {
dst := ServerConfig{
Host: "example.com",
Port: 8080,
}
src := ServerConfig{
Host: "localhost",
Port: 9090,
}
if err := mergo.Merge(&dst, src, mergo.WithOverride); err != nil {
t.Fatalf("mergo.Merge with WithOverride failed: %v", err)
}
if dst.Host != "localhost" {
t.Errorf("expected Host 'localhost', got %q", dst.Host)
}
if dst.Port != 9090 {
t.Errorf("expected Port 9090, got %d", dst.Port)
}
}
func TestMergeWithAppendSlice(t *testing.T) {
dst := ServerConfig{
Tags: []string{"primary"},
}
src := ServerConfig{
Tags: []string{"secondary", "backup"},
}
if err := mergo.Merge(&dst, src, mergo.WithAppendSlice); err != nil {
t.Fatalf("mergo.Merge with WithAppendSlice failed: %v", err)
}
expectedTags := []string{"primary", "secondary", "backup"}
if !reflect.DeepEqual(dst.Tags, expectedTags) {
t.Errorf("expected Tags %v, got %v", expectedTags, dst.Tags)
}
}
func TestMergeNilArguments(t *testing.T) {
var nilDst *ServerConfig
src := ServerConfig{Host: "localhost"}
err := mergo.Merge(nilDst, src)
if err == nil {
t.Errorf("expected error when merging into nil dst, got nil")
}
}
Seeder de origem
anônimo