options

package
v0.12.0 Latest Latest
Warning

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

Go to latest
Published: Feb 14, 2021 License: BSD-2-Clause Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Register

func Register(ns string, cfg interface{})

Register allows registering options so that they can be listed with List.

Types

type Help

type Help struct {
	Namespace string
	Name      string
	Text      string
}

Help contains information about an option.

func List

func List() (list []Help)

List returns a list of all registered options (using Register()).

type Options

type Options map[string]string

Options holds options in the form key=value.

func Parse

func Parse(in []string) (Options, error)

Parse takes a slice of key=value pairs and returns an Options type. The key may include namespaces, separated by dots. Example: "foo.bar=value". Keys are converted to lower-case.

func (Options) Apply

func (o Options) Apply(ns string, dst interface{}) error

Apply sets the options on dst via reflection, using the struct tag `option`. The namespace argument (ns) is only used for error messages.

func (Options) Extract

func (o Options) Extract(ns string) Options

Extract returns an Options type with all keys in namespace ns, which is also stripped from the keys. ns must end with a dot.

Jump to

Keyboard shortcuts

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