structure

package module
v0.59.0 Latest Latest
Warning

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

Go to latest
Published: Nov 6, 2024 License: Apache-2.0 Imports: 8 Imported by: 1

Documentation

Overview

Package structure defines a helper to retrieve structured data from the config

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func UnmarshalKey

func UnmarshalKey(cfg model.Reader, key string, target interface{}, opts ...UnmarshalKeyOption) error

UnmarshalKey retrieves data from the config at the given key and deserializes it to be stored on the target struct. It is implemented entirely using reflection, and does not depend upon details of the data model of the config. Target struct can use of struct tag of "yaml", "json", or "mapstructure" to rename fields

Types

type UnmarshalKeyOption

type UnmarshalKeyOption func(*featureSet)

UnmarshalKeyOption is an option that affects the enabled features in UnmarshalKey

var ConvertEmptyStringToNil UnmarshalKeyOption = func(fs *featureSet) {
	fs.convertEmptyStrNil = true
}

ConvertEmptyStringToNil allows UnmarshalKey to implicitly convert empty strings into nil slices

var EnableSquash UnmarshalKeyOption = func(fs *featureSet) {
	fs.allowSquash = true
}

EnableSquash allows UnmarshalKey to take advantage of `mapstructure`s `squash` feature a squashed field hoists its fields up a level in the marshalled representation and directly embeds them

Jump to

Keyboard shortcuts

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