config

package
v1.1.4 Latest Latest
Warning

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

Go to latest
Published: Feb 23, 2023 License: MIT Imports: 2 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// ContextConfigValue can be used as key to query the config object
	ContextConfigValue = "github.com/aellwein/config/v1/config.Cfg"
)

Variables

This section is empty.

Functions

func NewBuilder

func NewBuilder() *newBuilderT

NewBuilder creates a new config builder

Types

type Cfg

type Cfg interface {
	GetAll() map[string]interface{}
	Get(key string) interface{}
	GetString(key string) string
	GetBool(key string) bool
	GetInt(key string) int
	GetInt32(key string) int32
	GetInt64(key string) int64
	GetUint(key string) uint
	GetUint32(key string) uint32
	GetUint64(key string) uint64
	GetFloat64(key string) float64
	GetDuration(key string) time.Duration
	GetIntSlice(key string) []int
	GetSizeInBytes(key string) uint
	GetTime(key string) time.Time
	GetStringSlice(key string) []string

	Set(key string, val interface{})

	// Saves back the config (forces overwrite)
	Write() error
}

Cfg defines an interface which is capable to provide object for interaction with configuration.

type CfgOption

type CfgOption string

CfgOption provides a type for config options which can be passed using Options()

const (
	// NoErrorOnMissingCfgFileOption defines that there should be no error upon creation of Cfg if none of config files could be found.
	NoErrorOnMissingCfgFileOption CfgOption = "NoErrorOnMissingCfgFileOption"
)

type Context

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

Context is used to pass context with underlying config object to commands.

func NewContext

func NewContext(cfg Cfg) *Context

NewContext creates a context containing the given config object

func (*Context) Deadline

func (c *Context) Deadline() (deadline time.Time, ok bool)

Deadline has a no-op implementation of context.Context.Deadline()

func (*Context) Done

func (c *Context) Done() <-chan struct{}

Done has a no-op implementation of context.Context.Done()

func (*Context) Err

func (c *Context) Err() error

Err has a no-op implementation of context.Context.Err()

func (*Context) Value

func (c *Context) Value(key interface{}) interface{}

Value provides the actual method to get the config object from context

Jump to

Keyboard shortcuts

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