Beispiel
github.com/mitchellh/reflectwalk v1.0.2: SkipEntry
Verifiziertes Beispiel für golang github.com/mitchellh/reflectwalk v1.0.2: SkipEntry. Der Vertrag lief auf go 1.26 · linux alpine/x64 · docker und bestand.
sha256:305c7c25133ab70ccb27a1e83c8d9e9c91f2cb7644d8046f8249e22ee122a2bf
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
- 2
- 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 alpine/x64 · docker ed25519:c1973797be207ac4 | PASS | compile:SKIPPED · contract:PASS · load:PASS · resolve:PASS CONTAINER_RUN · golang@1 |
2026-08-21 |
| 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-07 |
Fall
HOW- Ziel
- verify github.com/mitchellh/reflectwalk.SkipEntry in pkg:golang/github.com/mitchellh/reflectwalk@v1.0.2
- Symbole
-
- github.com/mitchellh/reflectwalk.SkipEntry
- Erstellt
- 2026-08-21T00:38:41Z
Contract
- reflectwalk.SkipEntry returned from StructField skips walking the specified struct field
- reflectwalk.SkipEntry returned from Struct skips walking all fields within that struct
- reflectwalk.SkipEntry returned from Pointer skips dereferencing and walking into the pointer target
- reflectwalk.SkipEntry is a distinct sentinel error that does not abort the overall Walk operation
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 github.com/mitchellh/reflectwalk.SkipEntry in pkg:golang/github.com/mitchellh/reflectwalk@v1.0.2
Kind: HOW
Use EXACTLY these public packages and versions:
- pkg:golang/github.com/mitchellh/reflectwalk@v1.0.2
Demonstrate these symbols/APIs:
- github.com/mitchellh/reflectwalk.SkipEntry
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:7509dc85c01b5e98aadbeab293bab56c870392ff3311ec6dcaf8780db2458618","contract":["reflectwalk.SkipEntry returned from StructField skips walking the specified struct field","reflectwalk.SkipEntry returned from Struct skips walking all fields within that struct","reflectwalk.SkipEntry returned from Pointer skips dereferencing and walking into the pointer target","reflectwalk.SkipEntry is a distinct sentinel error that does not abort the overall Walk operation"],"goal":"verify github.com/mitchellh/reflectwalk.SkipEntry in pkg:golang/github.com/mitchellh/reflectwalk@v1.0.2","kind":"HOW","packages":["pkg:golang/github.com/mitchellh/reflectwalk@v1.0.2"],"schemaVersion":1,"symbols":["github.com/mitchellh/reflectwalk.SkipEntry"]},"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/mitchellh/reflectwalk@v1.0.2"],"schemaVersion":1,"subject":"pkg:golang/github.com/mitchellh/reflectwalk@v1.0.2","symbols":["github.com/mitchellh/reflectwalk.SkipEntry"],"verifierAdapter":"golang@1"}
module sample
go 1.26.6
require github.com/mitchellh/reflectwalk v1.0.2
github.com/mitchellh/reflectwalk v1.0.2 h1:G2LzWKi524PWgd3mLHV8Y5k7s6XUvT0Gef6zxSIeXaQ=
github.com/mitchellh/reflectwalk v1.0.2/go.mod h1:mSTlrgnPZtwu0c4WaC2kGObEpuNDbx0jmZXqmk4esnw=
package main
import (
"fmt"
"reflect"
"strings"
"github.com/mitchellh/reflectwalk"
)
type filterWalker struct {
visited []string
}
func (w *filterWalker) Struct(v reflect.Value) error {
return nil
}
func (w *filterWalker) StructField(sf reflect.StructField, v reflect.Value) error {
if strings.HasPrefix(sf.Name, "Hidden") {
return reflectwalk.SkipEntry
}
w.visited = append(w.visited, sf.Name)
return nil
}
type Config struct {
PublicField string
HiddenField string
ExtraField int
}
func main() {
cfg := Config{
PublicField: "visible",
HiddenField: "secret",
ExtraField: 42,
}
walker := &filterWalker{}
if err := reflectwalk.Walk(cfg, walker); err != nil {
panic(err)
}
fmt.Printf("Visited fields: %v\n", walker.visited)
}
{
"schemaVersion": 1,
"goal": "verify github.com/mitchellh/reflectwalk.SkipEntry in pkg:golang/github.com/mitchellh/reflectwalk@v1.0.2",
"kind": "HOW",
"packages": [
"pkg:golang/github.com/mitchellh/reflectwalk@v1.0.2"
],
"symbols": [
"github.com/mitchellh/reflectwalk.SkipEntry"
]
}
package main
import (
"errors"
"fmt"
"os"
"reflect"
"strings"
"github.com/mitchellh/reflectwalk"
)
func main() {
if err := runContract(); err != nil {
fmt.Fprintf(os.Stderr, "Contract verification failed: %v\n", err)
os.Exit(1)
}
fmt.Println("All reflectwalk.SkipEntry contract assertions passed successfully.")
}
type fieldFilterWalker struct {
visitedFields []string
}
func (w *fieldFilterWalker) Struct(v reflect.Value) error {
return nil
}
func (w *fieldFilterWalker) StructField(sf reflect.StructField, v reflect.Value) error {
if strings.HasPrefix(sf.Name, "Skip") {
return reflectwalk.SkipEntry
}
w.visitedFields = append(w.visitedFields, sf.Name)
return nil
}
type structFilterWalker struct {
structCount int
fieldCount int
skipStruct bool
}
func (w *structFilterWalker) Struct(v reflect.Value) error {
w.structCount++
if w.skipStruct {
return reflectwalk.SkipEntry
}
return nil
}
func (w *structFilterWalker) StructField(sf reflect.StructField, v reflect.Value) error {
w.fieldCount++
return nil
}
type pointerFilterWalker struct {
pointerVisited []string
primitiveCount int
skipPointer bool
}
func (w *pointerFilterWalker) Pointer(v reflect.Value) error {
w.pointerVisited = append(w.pointerVisited, v.Type().String())
if w.skipPointer {
return reflectwalk.SkipEntry
}
return nil
}
func (w *pointerFilterWalker) Primitive(v reflect.Value) error {
w.primitiveCount++
return nil
}
func runContract() error {
// Assertion 1: reflectwalk.SkipEntry returned from StructField skips walking the specified struct field
type SampleData struct {
KeepFirst string
SkipMiddle int
KeepLast bool
}
data1 := SampleData{
KeepFirst: "alpha",
SkipMiddle: 100,
KeepLast: true,
}
w1 := &fieldFilterWalker{}
if err := reflectwalk.Walk(data1, w1); err != nil {
return fmt.Errorf("unexpected error walking data1: %w", err)
}
if len(w1.visitedFields) != 2 || w1.visitedFields[0] != "KeepFirst" || w1.visitedFields[1] != "KeepLast" {
return fmt.Errorf("expected [KeepFirst KeepLast], got %v", w1.visitedFields)
}
// Assertion 2: reflectwalk.SkipEntry returned from Struct skips walking all fields within that struct
data2 := SampleData{
KeepFirst: "beta",
SkipMiddle: 200,
KeepLast: false,
}
w2 := &structFilterWalker{skipStruct: true}
if err := reflectwalk.Walk(data2, w2); err != nil {
return fmt.Errorf("unexpected error walking data2 with skipStruct: %w", err)
}
if w2.structCount != 1 || w2.fieldCount != 0 {
return fmt.Errorf("expected structCount 1 and fieldCount 0, got structCount=%d, fieldCount=%d", w2.structCount, w2.fieldCount)
}
// Assertion 3: reflectwalk.SkipEntry returned from Pointer skips dereferencing and walking into the pointer target
val := 42
ptrData := &val
w3 := &pointerFilterWalker{skipPointer: true}
if err := reflectwalk.Walk(ptrData, w3); err != nil {
return fmt.Errorf("unexpected error walking pointer: %w", err)
}
if len(w3.pointerVisited) != 1 || w3.primitiveCount != 0 {
return fmt.Errorf("expected pointer visited once and 0 primitives walked, got pointerVisited=%v, primitiveCount=%d", w3.pointerVisited, w3.primitiveCount)
}
// Assertion 4: reflectwalk.SkipEntry is a distinct sentinel error that does not abort the overall Walk operation
if reflectwalk.SkipEntry == nil {
return errors.New("reflectwalk.SkipEntry must not be nil")
}
if reflectwalk.SkipEntry.Error() != "skip this entry" {
return fmt.Errorf("expected SkipEntry error message %q, got %q", "skip this entry", reflectwalk.SkipEntry.Error())
}
return nil
}
Ursprungs-Seeder
anonym