Beispiel
go.uber.org/zap v1.28.0: New
Verifiziertes Beispiel für golang go.uber.org/zap v1.28.0: New. Der Vertrag lief auf go 1.26 · linux debian/x64 · docker und bestand.
sha256:c4650257b8985182a770e3be7861764b2937200603e693ec801f1fb23bbe56db
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-04 |
Fall
HOW- Ziel
- verify go.uber.org/zap.New in pkg:golang/go.uber.org/zap@v1.28.0
- Pakete
- Symbole
-
- go.uber.org/zap.New
- Erstellt
- 2026-09-04T13:35:09Z
Contract
- zap.New initializes a Logger with base zap.Fields that are included in every emitted log entry
- zap.New with zap.Hooks executes registered callbacks on each logged entry
- zap.New with zap.AddCaller records caller file and line location for logged entries
- zap.New with nil core returns a safe no-op logger that does not panic on log calls
Dateien
- PROMPT.md
- csx.json
- go.mod
- go.sum
- sample.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 go.uber.org/zap.New in pkg:golang/go.uber.org/zap@v1.28.0
Kind: HOW
Use EXACTLY these public packages and versions:
- pkg:golang/go.uber.org/zap@v1.28.0
Demonstrate these symbols/APIs:
- go.uber.org/zap.New
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:b879b3dc4021a6b74db35e278c5cff65c93c7d10e037098356fa68ce303a776f","contract":["zap.New initializes a Logger with base zap.Fields that are included in every emitted log entry","zap.New with zap.Hooks executes registered callbacks on each logged entry","zap.New with zap.AddCaller records caller file and line location for logged entries","zap.New with nil core returns a safe no-op logger that does not panic on log calls"],"goal":"verify go.uber.org/zap.New in pkg:golang/go.uber.org/zap@v1.28.0","kind":"HOW","packages":["pkg:golang/go.uber.org/zap@v1.28.0"],"schemaVersion":1,"symbols":["go.uber.org/zap.New"]},"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/go.uber.org/zap@v1.28.0"],"schemaVersion":1,"subject":"pkg:golang/go.uber.org/zap@v1.28.0","symbols":["go.uber.org/zap.New"],"verifierAdapter":"golang@1"}
module sample
go 1.23
require go.uber.org/zap v1.28.0
require go.uber.org/multierr v1.10.0 // indirect
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/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
github.com/stretchr/testify v1.8.1 h1:w7B6lhMri9wdJUVmEZPGGhZzrYTPvgJArz7wNPgYKsk=
github.com/stretchr/testify v1.8.1/go.mod h1:w2LPCIKwWwSfY2zedu0+kehJoqGctiVI29o6fzry7u4=
go.uber.org/goleak v1.3.0 h1:2K3zAYmnTNqV73imy9J1T3WC+gmCePx2hEGkimedGto=
go.uber.org/goleak v1.3.0/go.mod h1:CoHD4mav9JJNrW/WLlf7HGZPjdw8EucARQHekz1X6bE=
go.uber.org/multierr v1.10.0 h1:S0h4aNzvfcFsC3dRF1jLoaov7oRaKqRGC/pUEJ2yvPQ=
go.uber.org/multierr v1.10.0/go.mod h1:20+QtiLqy0Nd6FdQB9TLXag12DsQkrbs3htMFfDN80Y=
go.uber.org/zap v1.28.0 h1:IZzaP1Fv73/T/pBMLk4VutPl36uNC+OSUh3JLG3FIjo=
go.uber.org/zap v1.28.0/go.mod h1:rDLpOi171uODNm/mxFcuYWxDsqWSAVkFdX4XojSKg/Q=
go.yaml.in/yaml/v3 v3.0.4 h1:tfq32ie2Jv2UxXFdLJdh3jXuOzWiL1fo0bu/FbuKpbc=
go.yaml.in/yaml/v3 v3.0.4/go.mod h1:DhzuOOF2ATzADvBadXxruRBLzYTpT36CKvDb3+aBEFg=
gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA=
gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
package sample
import (
"go.uber.org/zap"
"go.uber.org/zap/zapcore"
)
// NewLogger constructs a zap.Logger wrapping the core with optional settings.
func NewLogger(core zapcore.Core, options ...zap.Option) *zap.Logger {
return zap.New(core, options...)
}
// NewLoggerWithHook constructs a zap.Logger with an attached entry hook.
func NewLoggerWithHook(core zapcore.Core, hook func(zapcore.Entry) error, options ...zap.Option) *zap.Logger {
opts := append([]zap.Option{zap.Hooks(hook)}, options...)
return zap.New(core, opts...)
}
{
"schemaVersion": 1,
"goal": "verify go.uber.org/zap.New in pkg:golang/go.uber.org/zap@v1.28.0",
"kind": "HOW",
"packages": [
"pkg:golang/go.uber.org/zap@v1.28.0"
],
"symbols": [
"go.uber.org/zap.New"
]
}
package main
import (
"fmt"
"os"
"sample"
"go.uber.org/zap"
"go.uber.org/zap/zapcore"
"go.uber.org/zap/zaptest/observer"
)
func main() {
// 1. zap.New initializes a Logger with base zap.Fields that are included in every emitted log entry
core1, logs1 := observer.New(zapcore.InfoLevel)
logger1 := sample.NewLogger(core1, zap.Fields(zap.String("service", "auth-service")))
logger1.Info("user login", zap.String("user", "alice"))
entries1 := logs1.All()
if len(entries1) != 1 {
fmt.Fprintf(os.Stderr, "contract failed: expected 1 log entry, got %d\n", len(entries1))
os.Exit(1)
}
ctx1 := entries1[0].ContextMap()
if ctx1["service"] != "auth-service" {
fmt.Fprintf(os.Stderr, "contract failed: missing or invalid 'service' field: %#v\n", ctx1)
os.Exit(1)
}
if ctx1["user"] != "alice" {
fmt.Fprintf(os.Stderr, "contract failed: missing or invalid 'user' field: %#v\n", ctx1)
os.Exit(1)
}
// 2. zap.New with zap.Hooks executes registered callbacks on each logged entry
core2, _ := observer.New(zapcore.InfoLevel)
var hookedMessages []string
hook := func(entry zapcore.Entry) error {
hookedMessages = append(hookedMessages, entry.Message)
return nil
}
logger2 := sample.NewLoggerWithHook(core2, hook)
logger2.Info("first event")
logger2.Info("second event")
if len(hookedMessages) != 2 || hookedMessages[0] != "first event" || hookedMessages[1] != "second event" {
fmt.Fprintf(os.Stderr, "contract failed: hook was not called properly: %#v\n", hookedMessages)
os.Exit(1)
}
// 3. zap.New with zap.AddCaller records caller file and line location for logged entries
core3, logs3 := observer.New(zapcore.InfoLevel)
logger3 := sample.NewLogger(core3, zap.AddCaller())
logger3.Info("caller test")
entries3 := logs3.All()
if len(entries3) != 1 {
fmt.Fprintf(os.Stderr, "contract failed: expected 1 log entry, got %d\n", len(entries3))
os.Exit(1)
}
if !entries3[0].Caller.Defined {
fmt.Fprintf(os.Stderr, "contract failed: caller is not defined\n")
os.Exit(1)
}
if entries3[0].Caller.File == "" || entries3[0].Caller.Line == 0 {
fmt.Fprintf(os.Stderr, "contract failed: caller file or line empty: %#v\n", entries3[0].Caller)
os.Exit(1)
}
// 4. zap.New with nil core returns a safe no-op logger that does not panic on log calls
logger4 := sample.NewLogger(nil)
if logger4 == nil {
fmt.Fprintf(os.Stderr, "contract failed: zap.New(nil) returned nil logger\n")
os.Exit(1)
}
logger4.Debug("nop debug")
logger4.Info("nop info")
logger4.Warn("nop warn")
logger4.Error("nop error")
fmt.Println("PASS")
}
Ursprungs-Seeder
anonym