config

package
v0.0.0-...-5623d4f Latest Latest
Warning

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

Go to latest
Published: May 12, 2019 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Has

func Has(path string) bool

Types

type Config

type Config struct {
	Map map[string]interface{}
}

Config holds a nested map of config values and provides helper functions for easier access and type casting.

func (*Config) Get

func (c *Config) Get(path string) Value

Get returns the raw at the given path e.g. "redis.host"

func (*Config) Has

func (c *Config) Has(path string) bool

Has returns whether the config has a raw at the given path e.g. "redis.host"

type Provider

type Provider interface {
	Has(string) bool
	Get(string) Value
}
var DefaultProvider Provider

func New

func New(content map[string]interface{}) Provider

type Value

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

Value is returned from Get and has receiver methods for casting to various types.

func Get

func Get(path string) Value

func (Value) Bool

func (v Value) Bool(defaults ...bool) bool

Bool converts the raw to a bool and panics if it cannot be represented. The first default is returned if raw is not defined.

func (Value) Int

func (v Value) Int(defaults ...int) int

Int converts the raw to an int and panics if it cannot be represented. The first default is returned if raw is not defined.

func (Value) String

func (v Value) String(defaults ...string) string

String converts the raw to a string. The first default is returned if raw is not defined.

Jump to

Keyboard shortcuts

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