common

package
v0.0.0-...-ee5be7b Latest Latest
Warning

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

Go to latest
Published: Jan 29, 2021 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func OverwriteConfigOpts

func OverwriteConfigOpts(options []ucfg.Option)

OverwriteConfigOpts allow to change the globally set config option

Types

type Config

type Config ucfg.Config

Config object to store hierarchical configurations into. See https://godoc.org/github.com/elastic/go-ucfg#Config

func LoadFile

func LoadFile(path string) (*Config, [md5.Size]byte, error)

func MergeConfigs

func MergeConfigs(cfgs ...*Config) (*Config, error)

func MustNewConfigFrom

func MustNewConfigFrom(from interface{}) *Config

MustNewConfigFrom creates a new Config object from the given input. From can be any kind of structured data (struct, map, array, slice).

If from is a string, the contents is treated like raw YAML input. The string will be parsed and a structure config object is build from the parsed result.

MustNewConfigFrom panics if an error occurs.

func NewConfig

func NewConfig() *Config

func NewConfigFrom

func NewConfigFrom(from interface{}) (*Config, error)

NewConfigFrom creates a new Config object from the given input. From can be any kind of structured data (struct, map, array, slice).

If from is a string, the contents is treated like raw YAML input. The string will be parsed and a structure config object is build from the parsed result.

func NewConfigWithYAML

func NewConfigWithYAML(in []byte, source string) (*Config, error)

func (*Config) Bool

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

func (*Config) Child

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

func (*Config) CountField

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

func (*Config) Float

func (c *Config) Float(name string, idx int) (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) (int64, error)

func (*Config) IsArray

func (c *Config) IsArray() bool

func (*Config) IsDict

func (c *Config) IsDict() bool

func (*Config) Merge

func (c *Config) Merge(from interface{}) error

func (*Config) MustName

func (c *Config) MustName(fallback ...string) string

func (*Config) Name

func (c *Config) Name() (string, error)

func (*Config) Path

func (c *Config) Path() string

func (*Config) PathOf

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

func (*Config) SetBool

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

func (*Config) SetChild

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

func (*Config) SetFloat

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

func (*Config) SetInt

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

func (*Config) SetString

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

func (*Config) String

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

func (*Config) Unpack

func (c *Config) Unpack(to interface{}) error

type ConfigNamespace

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

ConfigNamespace storing at most one configuration section by name and sub-section.

func (*ConfigNamespace) Config

func (ns *ConfigNamespace) Config() *Config

Config return the sub-configuration section if a section has been set.

func (*ConfigNamespace) IsSet

func (ns *ConfigNamespace) IsSet() bool

IsSet returns true if a sub-configuration section has been set.

func (*ConfigNamespace) Name

func (ns *ConfigNamespace) Name() string

Name returns the configuration sections it's name if a section has been set.

func (*ConfigNamespace) Unpack

func (ns *ConfigNamespace) Unpack(cfg *Config) error

Unpack unpacks a configuration with at most one sub object. An sub object is ignored if it is disabled by setting `enabled: false`. If the configuration passed contains multiple active sub objects, Unpack will return an error.

type FloatSet

type FloatSet map[float64]struct{}

func MakeFloatSet

func MakeFloatSet(floats ...float64) FloatSet

func MakeFloatSetFromStrings

func MakeFloatSetFromStrings(strings ...string) (FloatSet, error)

func (FloatSet) Add

func (set FloatSet) Add(f float64)

func (FloatSet) Count

func (set FloatSet) Count() int

func (FloatSet) Del

func (set FloatSet) Del(f float64)

func (FloatSet) Has

func (set FloatSet) Has(f float64) (exists bool)

type IntSet

type IntSet map[int]struct{}

func MakeIntSet

func MakeIntSet(ints ...int) IntSet

func MakeIntSetFromStrings

func MakeIntSetFromStrings(strings ...string) (IntSet, error)

func (IntSet) Add

func (set IntSet) Add(i int)

func (IntSet) Count

func (set IntSet) Count() int

func (IntSet) Del

func (set IntSet) Del(i int)

func (IntSet) Has

func (set IntSet) Has(s int) (exists bool)

type StringSet

type StringSet map[string]struct{}

func MakeStringSet

func MakeStringSet(strings ...string) StringSet

func (StringSet) Add

func (set StringSet) Add(s string)

func (StringSet) Count

func (set StringSet) Count() int

func (StringSet) Del

func (set StringSet) Del(s string)

func (StringSet) Has

func (set StringSet) Has(s string) (exists bool)

func (StringSet) ToSlice

func (set StringSet) ToSlice() []string

type UintSet

type UintSet map[uint]struct{}

func MakeUintSet

func MakeUintSet(uints ...uint) UintSet

func MakeUintSetFromStrings

func MakeUintSetFromStrings(strings ...string) (UintSet, error)

func (UintSet) Add

func (set UintSet) Add(i uint)

func (UintSet) Count

func (set UintSet) Count() int

func (UintSet) Del

func (set UintSet) Del(i uint)

func (UintSet) Has

func (set UintSet) Has(s uint) (exists bool)

Jump to

Keyboard shortcuts

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