conf

package
v1.3.1 Latest Latest
Warning

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

Go to latest
Published: Sep 7, 2021 License: Apache-2.0 Imports: 9 Imported by: 2 modules, 1 package

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Init

func Init()

func KeyMap

func KeyMap() map[string]interface{}

func OnChange

func OnChange(cb func(*Config))

func Unmarshal

func Unmarshal(key string, object interface{}) error

Types

type Config

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

func New

func New() *Config

func (*Config) GetKeyMap

func (c *Config) GetKeyMap() map[string]interface{}

func (*Config) Keys

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

Keys returns the slice of all flattened keys in the loaded configuration sorted alphabetically.

func (*Config) Load

func (c *Config) Load(provider Provider, parser Parser) error

Load takes a Provider that either provides a parsed config map[string]interface{} in which case pa (Parser) can be nil, or raw bytes to be parsed, where a Parser can be provided to parse.

func (*Config) OnChange

func (c *Config) OnChange(cb func(*Config))

func (*Config) Print

func (c *Config) Print() string

Print prints a key -> value string representation of the config map with keys sorted alphabetically.

func (*Config) SetDelimiter

func (c *Config) SetDelimiter(delimiter string)

func (*Config) Unmarshal

func (c *Config) Unmarshal(key string, object interface{}) error

Unmarshal unmarshals a given key path into the given struct using the mapstructure lib. If no path is specified, the whole map is unmarshalled. `conf` is the struct field tag used to match field names.

type Parser

type Parser interface {
	Marshal(map[string]interface{}) ([]byte, error)
	Unmarshal([]byte) (map[string]interface{}, error)
}

type Provider

type Provider interface {
	ReadBytes() ([]byte, error)
	Watch(func()) error
}

Directories

Path Synopsis
parser
provider

Jump to

Keyboard shortcuts

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