ucfg

package module
v0.1.1 Latest Latest
Warning

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

Go to latest
Published: Mar 23, 2016 License: Apache-2.0 Imports: 7 Imported by: 679

README

ucfg

Build Status

Documentation

Index

Constants

This section is empty.

Variables

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

	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")
)

error Reasons

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

error classes

Functions

This section is empty.

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) String

func (c *Config) String(name string, idx int, opts ...Option) (string, 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 occured 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

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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