options

package
v27.0.0-rc.2+incompatible Latest Latest
Warning

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

Go to latest
Published: Jun 17, 2024 License: Apache-2.0 Imports: 2 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package options provides a way to pass unstructured sets of options to a component expecting a strongly-typed configuration structure.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GenerateFromModel

func GenerateFromModel(options Generic, model interface{}) (interface{}, error)

GenerateFromModel takes the generic options, and tries to build a new instance of the model's type by matching keys from the generic options to fields in the model.

The return value is of the same type than the model (including a potential pointer qualifier).

Types

type CannotSetFieldError

type CannotSetFieldError struct {
	Field string
	Type  string
}

CannotSetFieldError is the error returned when the generic parameters hold a value for a field that cannot be set in the destination structure.

func (CannotSetFieldError) Error

func (e CannotSetFieldError) Error() string

type Generic

type Generic map[string]any

Generic is a basic type to store arbitrary settings.

type NoSuchFieldError

type NoSuchFieldError struct {
	Field string
	Type  string
}

NoSuchFieldError is the error returned when the generic parameters hold a value for a field absent from the destination structure.

func (NoSuchFieldError) Error

func (e NoSuchFieldError) Error() string

type TypeMismatchError

type TypeMismatchError struct {
	Field      string
	ExpectType string
	ActualType string
}

TypeMismatchError is the error returned when the type of the generic value for a field mismatches the type of the destination structure.

func (TypeMismatchError) Error

func (e TypeMismatchError) Error() string

Jump to

Keyboard shortcuts

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