config

package module
v0.1.4 Latest Latest
Warning

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

Go to latest
Published: Aug 24, 2023 License: MIT Imports: 7 Imported by: 2

README

-config-go

Standardised config via files, env-vars, and cli flags

-config-go is part of the kiss-my-package set used by apps like FaceMasq, PaperBag, Celestial, Executrix, and more

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Reset

func Reset(ctx context.Context) context.Context

Types

type Configuration

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

func FromContext

func FromContext(ctx context.Context) *Configuration

func New

func New(ctx context.Context, schema *jsonschema.Schema, appName string, folders ...string) (*Configuration, error)

func ToContext

func ToContext(ctx context.Context, schema *jsonschema.Schema, appName string, folders ...string) (*Configuration, context.Context)

func (*Configuration) File

func (c *Configuration) File() string

func (*Configuration) Get

func (c *Configuration) Get(key string) interface{}

func (*Configuration) ToContext

func (cfg *Configuration) ToContext(ctx context.Context) context.Context

type DefaultConfig

type DefaultConfig map[string]interface{}

func Default

func Default(args ...DefaultPairs) DefaultConfig

func (*DefaultConfig) Set

func (dConf *DefaultConfig) Set(key string, value interface{})

type DefaultPairs

type DefaultPairs struct {
	Key   string
	Value interface{}
}

type Folders

type Folders []string

func DefaultFolders

func DefaultFolders(container string) *Folders

func (*Folders) Add

func (f *Folders) Add(folder string)

func (*Folders) AddAll

func (f *Folders) AddAll(folders []string)

func (*Folders) Get

func (f *Folders) Get() []string

func (*Folders) Remove

func (f *Folders) Remove(folder string)

func (*Folders) RemoveAll

func (f *Folders) RemoveAll(folders []string)

func (*Folders) Set

func (f *Folders) Set(folders []string)

type Type

type Type int
const (
	YAML Type = iota // YAML is used to idicate the ConfigFile should be in YAML format.
	JSON             // JSON is used to idicate the ConfigFile should be in JSON format.
	TOML             // TOML is used to idicate the ConfigFile should be in TOML format.
)

Jump to

Keyboard shortcuts

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