ucfg

package module
v0.2.1 Latest Latest
Warning

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

Go to latest
Published: May 4, 2016 License: Apache-2.0 Imports: 9 Imported by: 642

README

ucfg

Build Status

Go Report Card

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrMissing = errors.New("missing field")

	ErrDuplicateValidator = errors.New("validator already registered")

	ErrTypeNoArray = errors.New("field is no array")

	ErrTypeMismatch = errors.New("type mismatch")

	ErrKeyTypeNotString = errors.New("key must be a string")

	ErrIndexOutOfRange = errors.New("out of range index")

	ErrPointerRequired = errors.New("pointer required for unpacking configurations")

	ErrArraySizeMistach = errors.New("Array size mismatch")

	ErrExpectedObject = errors.New("expected object")

	ErrNilConfig = errors.New("config is nil")

	ErrNilValue = errors.New("nil value is invalid")

	ErrTODO = errors.New("TODO - implement me")

	ErrDuplicateKeey = errors.New("duplicate key")

	ErrOverflow = errors.New("integer overflow")

	ErrNegative = errors.New("negative value")

	ErrZeroValue = errors.New("zero value")

	ErrRequired = errors.New("missing required field")

	ErrEmpty = errors.New("empty field")
)

error Reasons

View Source
var (
	ErrConfig         = errors.New("Configuration error")
	ErrImplementation = errors.New("Implementation error")
	ErrUnknown        = errors.New("Unspecified")
)

error classes

Functions

func RegisterValidator added in v0.2.0

func RegisterValidator(name string, cb ValidatorCallback) error

Types

type Config

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

func New

func New() *Config

func NewFrom

func NewFrom(from interface{}, opts ...Option) (*Config, error)

func (*Config) Bool

func (c *Config) Bool(name string, idx int, opts ...Option) (bool, error)

func (*Config) Child

func (c *Config) Child(name string, idx int, opts ...Option) (*Config, error)

func (*Config) CountField

func (c *Config) CountField(name string) (int, error)

number of elements for this field. If config value is a list, returns number of elements in list

func (*Config) Float

func (c *Config) Float(name string, idx int, opts ...Option) (float64, error)

func (*Config) GetFields

func (c *Config) GetFields() []string

func (*Config) HasField

func (c *Config) HasField(name string) bool

func (*Config) Int

func (c *Config) Int(name string, idx int, opts ...Option) (int64, error)

func (*Config) Merge

func (c *Config) Merge(from interface{}, options ...Option) error

func (*Config) Parent added in v0.1.0

func (c *Config) Parent() *Config

func (*Config) Path added in v0.1.0

func (c *Config) Path(sep string) string

func (*Config) PathOf added in v0.1.0

func (c *Config) PathOf(field, sep string) string

func (*Config) SetBool

func (c *Config) SetBool(name string, idx int, value bool, opts ...Option) error

func (*Config) SetChild

func (c *Config) SetChild(name string, idx int, value *Config, opts ...Option) error

func (*Config) SetFloat

func (c *Config) SetFloat(name string, idx int, value float64, opts ...Option) error

func (*Config) SetInt

func (c *Config) SetInt(name string, idx int, value int64, opts ...Option) error

func (*Config) SetString

func (c *Config) SetString(name string, idx int, value string, opts ...Option) error

func (*Config) SetUint added in v0.2.0

func (c *Config) SetUint(name string, idx int, value uint64, opts ...Option) error

func (*Config) String

func (c *Config) String(name string, idx int, opts ...Option) (string, error)

func (*Config) Uint added in v0.2.0

func (c *Config) Uint(name string, idx int, opts ...Option) (uint64, error)

func (*Config) Unpack

func (c *Config) Unpack(to interface{}, options ...Option) error

type Error added in v0.1.0

type Error interface {
	error
	Reason() error

	// error class, one of ErrConfig, ErrImplementation, ErrUnknown
	Class() error

	Message() string

	// [optional] path of config element error occurred for
	Path() string

	// [optional] stack trace
	Trace() string
}

type Meta added in v0.1.0

type Meta struct {
	Source string
}

Meta holds additional meta data per config value

type Option

type Option func(*options)

func MetaData added in v0.1.0

func MetaData(meta Meta) Option

func PathSep

func PathSep(sep string) Option

func StructTag

func StructTag(tag string) Option

func ValidatorTag added in v0.2.0

func ValidatorTag(tag string) Option

type Unpacker added in v0.2.0

type Unpacker interface {
	Unpack(interface{}) error
}

type Validator added in v0.2.0

type Validator interface {
	Validate() error
}

type ValidatorCallback added in v0.2.0

type ValidatorCallback func(interface{}, string) error

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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