opts

package
v0.2.5 Latest Latest
Warning

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

Go to latest
Published: Sep 1, 2016 License: GPL-2.0 Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ValidateEnv

func ValidateEnv(val string) (string, error)

ValidateEnv validates an environment variable and returns it. If no value is specified, it returns the current value using os.Getenv.

Types

type ListOpts

type ListOpts struct {
	// contains filtered or unexported fields
}

ListOpts holds a list of values and a validation function

func NewListOpts

func NewListOpts(validator ValidatorFunc) ListOpts

NewListOpts creates a new ListOpts with the specified validator.

func NewListOptsRef

func NewListOptsRef(values *[]string, validator ValidatorFunc) *ListOpts

NewListOptsRef creates a new ListOpts with the specified values and validator.

func (*ListOpts) GetAll

func (opts *ListOpts) GetAll() []string

GetAll returns the values of slice.

func (*ListOpts) Set

func (opts *ListOpts) Set(value string) error

Set validates if needed the input value and adds it to the internal slice.

func (*ListOpts) String

func (opts *ListOpts) String() string

type MapOpts

type MapOpts struct {
	// contains filtered or unexported fields
}

MapOpts holds a map of values and validation function

func NewMapOpts

func NewMapOpts(validator ValidatorFunc) MapOpts

NewMapOpts creates a new MapOpts with the specified map of values and a validator.

func NewMapOptsRef

func NewMapOptsRef(values *map[string]string, validator ValidatorFunc) *MapOpts

NewMapOptsRef creates a new MapOpts with the specified values and validator.

func (*MapOpts) GetAll

func (opts *MapOpts) GetAll() map[string]string

GetAll returns the values of MapOpts as a map.

func (*MapOpts) Set

func (opts *MapOpts) Set(value string) error

Set validates if needed the input value and add it to the internal map, by splitting on '='.

func (*MapOpts) String

func (opts *MapOpts) String() string

type ValidatorFunc

type ValidatorFunc func(val string) (string, error)

ValidatorFunc defines a validator function that returns a validated string and/or an error.

Jump to

Keyboard shortcuts

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