Documentation ¶
Index ¶
- Constants
- Variables
- func AutoReload() func(*LoadOptions)
- func IsUnfoundLocation(err error) bool
- func Watch(w Watcher) func(*LoadOptions)
- func WatchContext(w Watcher, ctx context.Context) func(*LoadOptions)
- type BaseBox
- type Box
- type ConfigEncodeError
- type ConfigFormat
- type ConfigFormats
- type ConfigParseError
- type Enviropment
- type FileBox
- type Flag
- type Flags
- type FlagsUsing
- type LoadOptions
- type Locations
- func (l *Locations) Add(locations ...string)
- func (l *Locations) AddJoin(locationParts ...string)
- func (l *Locations) ExpandLocation(path string) string
- func (l *Locations) Init(applicationName string, locations ...string) *Locations
- func (l *Locations) Locate(filename string) (box Box, err error)
- func (l *Locations) LocatePath(filename string) (string, error)
- type Locker
- type MarshalFunc
- type Options
- type Pantry
- func (p *Pantry) AddLocation(locationParts ...string)
- func (p *Pantry) AddLocations(locations ...string)
- func (p *Pantry) Box(box Box, v interface{}) error
- func (p *Pantry) BoxAs(box Box, v interface{}, format string) error
- func (p *Pantry) BoxWith(box Box, v interface{}, marshaler MarshalFunc) error
- func (p *Pantry) Decode(r io.Reader, v interface{}, format string) error
- func (p *Pantry) Encode(w io.Writer, v interface{}, format string) error
- func (p *Pantry) Init(applicationName string, locations ...string) *Pantry
- func (p *Pantry) Load(path string, v interface{}, opt ...func(*LoadOptions)) (Box, error)
- func (p *Pantry) LoadAs(path string, v interface{}, format string, opts ...func(*LoadOptions)) (Box, error)
- func (p *Pantry) LoadWith(path string, v interface{}, unmarshaler UnmarshalFunc) (string, error)
- func (p *Pantry) Locate(filename string) (Box, error)
- func (p *Pantry) LocatePath(filename string) (string, error)
- func (p *Pantry) Marshal(v interface{}, format string) (b []byte, err error)
- func (p *Pantry) MarshalWith(v interface{}, marshaler MarshalFunc) (b []byte, err error)
- func (p *Pantry) Save(path string, v interface{}) (Box, error)
- func (p *Pantry) SaveAs(path string, v interface{}, format string) (Box, error)
- func (p *Pantry) SaveWith(path string, v interface{}, marshaler MarshalFunc) (string, error)
- func (p *Pantry) UnBox(box Box, v interface{}) error
- func (p *Pantry) UnBoxAs(box Box, v interface{}, format string) error
- func (p *Pantry) UnBoxWith(box Box, v interface{}, unmarshaler UnmarshalFunc) error
- func (p *Pantry) Unmarshal(b []byte, v interface{}, format string) error
- func (p *Pantry) UnmarshalWith(b []byte, v interface{}, unmarshaler UnmarshalFunc) error
- type Tag
- type Tags
- type URLBox
- type UnfoundLocation
- type UnmarshalFunc
- type UnsupportedConfigError
- type UnsupportedFlagTypeError
- type Watcher
Constants ¶
const ( LocationConfigDir = "${configdir}" LocationApplicationDir = "${appdir}" LocationCurrentDir = "${curdir}" LocationHomeDir = "${home}" )
Variables ¶
var Formats = ConfigFormats{}
Formats contains marshalers and unmarshalers for different file formats
Functions ¶
func AutoReload ¶
func AutoReload() func(*LoadOptions)
func IsUnfoundLocation ¶
func Watch ¶
func Watch(w Watcher) func(*LoadOptions)
func WatchContext ¶
func WatchContext(w Watcher, ctx context.Context) func(*LoadOptions)
Types ¶
type Box ¶
type Box interface { Path() string Get() ([]byte, error) Set(data []byte) error Watch(task func(err error)) error WatchContext(ctx context.Context, task func(err error)) error }
Box
type ConfigEncodeError ¶
type ConfigEncodeError struct {
// contains filtered or unexported fields
}
ConfigEncodeError denotes failing to encode configuration
func (ConfigEncodeError) Error ¶
func (e ConfigEncodeError) Error() string
Returns the formatted configuration error.
type ConfigFormat ¶
type ConfigFormat struct { Marshal MarshalFunc Unmarshal UnmarshalFunc }
type ConfigFormats ¶
type ConfigFormats map[string]*ConfigFormat
func (ConfigFormats) Register ¶
func (c ConfigFormats) Register(format string, m MarshalFunc, um UnmarshalFunc)
Register format marshaler and unmarphaler
func (ConfigFormats) Search ¶
func (c ConfigFormats) Search(format string) (*ConfigFormat, error)
type ConfigParseError ¶
type ConfigParseError struct {
// contains filtered or unexported fields
}
ConfigParseError denotes failing to parse configuration file.
func (ConfigParseError) Error ¶
func (e ConfigParseError) Error() string
Returns the formatted configuration error.
type Enviropment ¶
type Flags ¶
type Flags struct { Using FlagsUsing FlagSet *flag.FlagSet Args []string ConfigPathFlag string Hierarchically bool // contains filtered or unexported fields }
func (*Flags) GetConfigPath ¶
type FlagsUsing ¶
type FlagsUsing int
const ( FlagsDontUse FlagsUsing = iota FlagsUsePredefined FlagsUseAll )
type Locations ¶
type Locations struct { ApplicationName string List []string // contains filtered or unexported fields }
func NewLocations ¶
func (*Locations) ExpandLocation ¶
type Locker ¶
type Locker interface { Lock() Unlock() }
Locker interface is used for exlusive access to a variable if it realized.
type MarshalFunc ¶
MarshalFunc is any marshaler.
type Options ¶
type Options struct { Flags Flags Enviropment Enviropment Tags Tags DefaultFormat string }
Config processing options.
type Pantry ¶
Pantry is used to load config data from different sources.
func (*Pantry) AddLocation ¶
AddLocation adds searching location.
func (*Pantry) AddLocations ¶
AddLocations adds searching locations.
func (*Pantry) BoxWith ¶
func (p *Pantry) BoxWith(box Box, v interface{}, marshaler MarshalFunc) error
func (*Pantry) Load ¶
func (p *Pantry) Load(path string, v interface{}, opt ...func(*LoadOptions)) (Box, error)
func (*Pantry) LoadWith ¶
func (p *Pantry) LoadWith(path string, v interface{}, unmarshaler UnmarshalFunc) (string, error)
func (*Pantry) LocatePath ¶
LocatePath looks for the file in previously added locations.
func (*Pantry) MarshalWith ¶
func (p *Pantry) MarshalWith(v interface{}, marshaler MarshalFunc) (b []byte, err error)
func (*Pantry) SaveWith ¶
func (p *Pantry) SaveWith(path string, v interface{}, marshaler MarshalFunc) (string, error)
func (*Pantry) UnBoxWith ¶
func (p *Pantry) UnBoxWith(box Box, v interface{}, unmarshaler UnmarshalFunc) error
func (*Pantry) Unmarshal ¶
Unmarshal unmarshals data as diffened format and applays enviropment variables and command line flags.
func (*Pantry) UnmarshalWith ¶
func (p *Pantry) UnmarshalWith(b []byte, v interface{}, unmarshaler UnmarshalFunc) error
UnmarshalWith unmarshals data by "unmarshaler" and applays enviropment variables and command line flags.
type UnfoundLocation ¶
type UnfoundLocation string
UnfoundLocation denotes that location is not found.
func (UnfoundLocation) Error ¶
func (str UnfoundLocation) Error() string
Returns the formatted configuration error.
type UnmarshalFunc ¶
UnmarshalFunc is any unmarshaler.
type UnsupportedConfigError ¶
type UnsupportedConfigError string
UnsupportedConfigError denotes encountering an unsupported configuration filetype.
func (UnsupportedConfigError) Error ¶
func (e UnsupportedConfigError) Error() string
Returns the formatted configuration error.
type UnsupportedFlagTypeError ¶
type UnsupportedFlagTypeError struct {
// contains filtered or unexported fields
}
func (UnsupportedFlagTypeError) Error ¶
func (e UnsupportedFlagTypeError) Error() string
Returns the formatted configuration error.