structwalk

package
v0.24.2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 2, 2022 License: Apache-2.0 Imports: 2 Imported by: 0

Documentation

Overview

Package structwalk allows you to "walk" the hierarchy of a struct. It is very similar to github.com/mitchellh/reflectwalk but allows you to change the visitor mid-walk.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Walk

func Walk(v Visitor, o interface{})

Walk traverses the hierarchy of o in depth-first order. It starts by calling v.Visit(o). If the visitor w returned by v.Visit(o) is not nil, Walk is invoked recursively with visitor w for each of the structs inside of o, followed by a call to w.Visit(nil).

o must be non-nil.

Types

type Visitor

type Visitor interface {
	Visit(value interface{}) (w Visitor)
}

Visitor will have its Visit method invoked for each struct value encountered by Walk. If w returned from Visit is non-nil, Walk will then visit each child of value with w. The final call after visiting all children will be to w.Visit(nil).

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL