config

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Feb 27, 2019 License: GPL-3.0 Imports: 7 Imported by: 3

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrNoSuchKey = errors.New("No such key")
)

Functions

This section is empty.

Types

type Config

type Config map[string]Value

Config : configuration structure definition

func Load

func Load(path string) (c Config, err error)

Load : loads a configuration structure from a file @path : path where the configuration is stored as a json file return (Config, error) : the Config struct parsed, error code

func Loads

func Loads(data []byte) (c Config, err error)

Loads : loads a configuration structure from a data buffer @data : buffer containing the configuration object return (Config, error) : the Config struct filled from data, error code

func (*Config) Debug

func (c *Config) Debug()

Debug : prints out the configuration in debug information

func (*Config) Dumps

func (c *Config) Dumps() (dump []byte, err error)

Dumps : Dumps Config structure into a byte slice return ([]byte, error) : byte slice and error code

func (*Config) Get

func (c *Config) Get(key string) (Value, error)

Get : get the Value associated to a key found in Config structure return (Value, error) : Value associated to key and error code

func (*Config) GetInt64

func (c *Config) GetInt64(key string) (i int64, err error)

GetInt64 gets the value associated to a key as int64 return (int64, error)

func (*Config) GetInt64Slice

func (c *Config) GetInt64Slice(key string) (i []int64, err error)

func (*Config) GetRequired

func (c *Config) GetRequired(key string) Value

GetRequired : get the Value associated to a key found in Config structure and exit if not available return (Value) : Value associated to key if it exists

func (*Config) GetRequiredInt64

func (c *Config) GetRequiredInt64(key string) int64

func (*Config) GetRequiredInt64Slice

func (c *Config) GetRequiredInt64Slice(key string) []int64

func (*Config) GetRequiredString

func (c *Config) GetRequiredString(key string) string

func (*Config) GetRequiredStringSlice

func (c *Config) GetRequiredStringSlice(key string) []string

func (*Config) GetRequiredSubConfig

func (c *Config) GetRequiredSubConfig(key string) Config

GetRequiredSubConfig : get a subconfig referenced by key return (Config)

func (*Config) GetRequiredUint64

func (c *Config) GetRequiredUint64(key string) uint64

func (*Config) GetRequiredUint64Slice

func (c *Config) GetRequiredUint64Slice(key string) []uint64

func (*Config) GetString

func (c *Config) GetString(key string) (string, error)

GetString gets the value associated to a key as string return (string, error)

func (*Config) GetStringSlice

func (c *Config) GetStringSlice(key string) (s []string, err error)

func (*Config) GetSubConfig

func (c *Config) GetSubConfig(key string) (Config, error)

GetSubConfig : get a subconfig referenced by key return (Config, error)

func (*Config) GetUint64

func (c *Config) GetUint64(key string) (u uint64, err error)

GetUint64 gets the value associated to a key as uint64 return (uint64, error)

func (*Config) GetUint64Slice

func (c *Config) GetUint64Slice(key string) (u []uint64, err error)

func (*Config) HasKey

func (c *Config) HasKey(key string) bool

HasKey returns true if the configuration has the given key

func (*Config) Set

func (c *Config) Set(key string, value interface{})

Set : set parameter identified by key of the Config struct with a Value

type Value

type Value interface{}

Value : stored in the configuration

Jump to

Keyboard shortcuts

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