config

package
v0.1.14 Latest Latest
Warning

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

Go to latest
Published: Aug 12, 2022 License: Unlicense Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ComposeEnvName

func ComposeEnvName(appName, group, name string) string

func IfErrNotNilPanic

func IfErrNotNilPanic(err error)

IfErrNotNilPanic is a helper for functions that should never error as errors are purely programmer errors and not error conditions.

func Item

func Item(m *types.Metadata) (t types.Item)

Item takes a Metadata and creates the appropriate item type for it.

func List

func List(items ...string) []string

List is a helper that uses variadic parameters to return a slice of strings.

func NewBool

func NewBool(m *types.Metadata) (b *types.BooT)

NewBool creates a new boolean types.Item

func NewDuration

func NewDuration(m *types.Metadata) (b *types.DurT)

NewDuration creates a new duration types.Item

func NewFloat

func NewFloat(m *types.Metadata) (b *types.FltT)

NewFloat creates a new floating point types.Item

func NewInt

func NewInt(m *types.Metadata) (b *types.IntT)

NewInt creates a new integer types.Item

func NewList

func NewList(m *types.Metadata) (b *types.LstT)

NewList creates a new list of strings types.Item

func NewString

func NewString(m *types.Metadata) (b *types.StrT)

NewString creates a new string types.Item

func NewUint

func NewUint(m *types.Metadata) (b *types.UinT)

NewUint creates a new unsigned integer types.Item

Types

type Configs

type Configs struct {
	sync.Mutex
	// contains filtered or unexported fields
}

func Create

func Create(appName string, items ...types.Desc) (c Configs)

Create a new configuration from a slice of item descriptors.

func (*Configs) Get

func (c *Configs) Get(group, name string) (t types.Item, err error)

Get returns a named item from the Configs

func (*Configs) GetByName

func (c *Configs) GetByName(name string) (t Types)

func (*Configs) GetEnvString

func (c *Configs) GetEnvString(group, name string) (envName string, err error)

func (*Configs) GetGroup

func (c *Configs) GetGroup(group string) (t TypeGroup)

func (*Configs) GetGroups

func (c *Configs) GetGroups() (tg TypesGrouped)

func (*Configs) GetHelp

func (c *Configs) GetHelp(name, group string, detailed bool) (text string,
	err error)

func (*Configs) Load

func (c *Configs) Load(filename string) (err error)

func (*Configs) LoadAllFromEnv

func (c *Configs) LoadAllFromEnv()

func (*Configs) LoadFromEnv

func (c *Configs) LoadFromEnv(group, name string) (err error)

func (*Configs) MarshalJSON

func (c *Configs) MarshalJSON() ([]byte, error)

MarshalJSON returns the JSON for the current state of a Configs

func (*Configs) Save

func (c *Configs) Save(filename string) (err error)

func (*Configs) UnmarshalJSON

func (c *Configs) UnmarshalJSON(bytes []byte) error

UnmarshalJSON loads a Configs with the values in a JSON string

type TypeGroup

type TypeGroup struct {
	Name string
	Types
}

type Types

type Types []types.Item

func (Types) Len

func (t Types) Len() int

func (Types) Less

func (t Types) Less(i, j int) bool

func (Types) Swap

func (t Types) Swap(i, j int)

type TypesGrouped

type TypesGrouped []TypeGroup

func (TypesGrouped) Len

func (t TypesGrouped) Len() int

func (TypesGrouped) Less

func (t TypesGrouped) Less(i, j int) bool

func (TypesGrouped) Swap

func (t TypesGrouped) Swap(i, j int)

Jump to

Keyboard shortcuts

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