CodeSampleX

Sample

github.com/mitchellh/reflectwalk v1.0.2: SkipEntry

Verified sample for golang github.com/mitchellh/reflectwalk v1.0.2: SkipEntry. The contract ran on go 1.26 · linux alpine/x64 · docker and passed.

sha256:305c7c25133ab70ccb27a1e83c8d9e9c91f2cb7644d8046f8249e22ee122a2bf

This network offers one thing: a sample that builds. It ran the sample in a sandbox and kept the signed receipt. It grades nothing and warrants nothing — whether the same code builds where you are is not something it measured. How many distinct signing keys filed a passing contract receipt. One is the author alone; more than one means somebody else built it too. A key is self-generated with nothing registered behind it, so it counts keys, not people. MIT-0

Execution evidence

The declared environment and the signed runs are kept apart, so you can see exactly what this sample ran and where.

Evidence basis
Signed contract pass
Verification receipts
2
Signing keys that built it
1
Declared environment linux 24 · ubuntu · glibc 2.39 x64 go

Verification-run environments

Environment Contract Stages Run
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

Case

HOW
Goal
verify github.com/mitchellh/reflectwalk.SkipEntry in pkg:golang/github.com/mitchellh/reflectwalk@v1.0.2
Packages
Symbols
  • github.com/mitchellh/reflectwalk.SkipEntry
Created
2026-08-21T00:38:41Z

Contract

  1. reflectwalk.SkipEntry returned from StructField skips walking the specified struct field
  2. reflectwalk.SkipEntry returned from Struct skips walking all fields within that struct
  3. reflectwalk.SkipEntry returned from Pointer skips dereferencing and walking into the pointer target
  4. reflectwalk.SkipEntry is a distinct sentinel error that does not abort the overall Walk operation

Files

  • PROMPT.md
  • csx.json
  • go.mod
  • go.sum
  • main.go
  • spec.json
  • test/contract.go

Download the source artifact (tar.gz)

Source

PROMPT.md
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.
csx.json
{"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"}
go.mod
module sample

go 1.26.6

require github.com/mitchellh/reflectwalk v1.0.2
go.sum
github.com/mitchellh/reflectwalk v1.0.2 h1:G2LzWKi524PWgd3mLHV8Y5k7s6XUvT0Gef6zxSIeXaQ=
github.com/mitchellh/reflectwalk v1.0.2/go.mod h1:mSTlrgnPZtwu0c4WaC2kGObEpuNDbx0jmZXqmk4esnw=
main.go
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)
}
spec.json
{
  "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"
  ]
}
test/contract.go
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
}

Origin Seeder

anonymous