framestruct

package
v0.134.0 Latest Latest
Warning

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

Go to latest
Published: Apr 29, 2022 License: Apache-2.0 Imports: 7 Imported by: 2

Documentation

Overview

Package framestruct provides functions to convert from any type to *data.Frame or data.Frames

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ToDataFrame

func ToDataFrame(name string, toConvert interface{}, opts ...FramestructOption) (*data.Frame, error)

ToDataFrame flattens an arbitrary struct or slice of structs into a *data.Frame

func ToDataFrames

func ToDataFrames(name string, toConvert interface{}, opts ...FramestructOption) (data.Frames, error)

ToDataFrames is a convenience wrapper around ToDataFrame. It will wrap the converted DataFrame in a data.Frames. Additionally, if the passed type satisfies the data.Framer interface, the function will delegate to that for the type conversion. If this function delegates to a data.Framer, it will use the data.Frame name defined by the type rather than passed to this function

Types

type FieldConverter added in v0.103.0

type FieldConverter func(interface{}) (interface{}, error)

FieldConverter is a function that takes the value of a field, converts it, and returns the new value as an interface

type FramestructOption added in v0.103.0

type FramestructOption func(cr *converter)

FramestructOption takes a converter and applies some configuration to it

func WithColumn0 added in v0.103.0

func WithColumn0(fieldname string) FramestructOption

WithColumn0 specifies the 0th column of the returned Data Frame. Using this option will override any `col0` framestruct tags that have been set. This is most useful when marshalling maps

func WithConverterFor added in v0.103.0

func WithConverterFor(fieldname string, c FieldConverter) FramestructOption

WithConverterFor configures a FieldConverter for a field with the name fieldname. This converter will be applied to fields _after_ the name structag is applied.

Jump to

Keyboard shortcuts

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