flat

package
v0.8.0 Latest Latest
Warning

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

Go to latest
Published: Jul 20, 2025 License: MIT Imports: 8 Imported by: 9

Documentation

Overview

Package flat provides a flat view of an arbitrary nested structs.

Index

Constants

This section is empty.

Variables

View Source
var ErrUnexpectedType = errors.New("unexpected type, expecting a pointer to struct")

ErrUnexpectedType is returned when flatten sees an unsupported type.

Functions

This section is empty.

Types

type Field

type Field interface {
	// Name returns the name for a given tag, if any
	// and also whatever the returned name is "explicit" by
	// the user or plugins are allowed to rewrite it.
	Name(tag string) (string, bool)

	Tag(key string) (string, bool)

	Meta() map[string]string

	Interface() any
	Set(string) error

	// returns the Ptr to this value.
	// It is used by complex decoders like uconfig-cue.
	Ptr() any
}

Field describe an interface to our flat structs fields.

type Fields

type Fields []Field

Fields is a slice of Field.

func View

func View(s any) (Fields, error)

View provides a flat view of the provided structs an array of fields. sub-struct fields are prefixed with the struct key (not type) followed by a dot, this is repeated for each nested level.

Jump to

Keyboard shortcuts

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