Documentation ¶
Index ¶
- func Bool(key string) bool
- func Clamp[T box.Number](v *Store, key string, f Getter[T], min, max T)
- func ClampDefault[T box.Number](v *Store, key string, f Getter[T], min, max, def T)
- func Float64(key string) float64
- func Int(key string) int
- func Int32(key string) int32
- func Int64(key string) int64
- func LoadJsonConfig(file string, obj any) error
- func MergeStore(s *Store) error
- func String(key string) string
- func Uint(key string) uint
- func Uint16(key string) uint16
- func Uint32(key string) uint32
- func Uint64(key string) uint64
- func UnmarshalKey(path string, o any) error
- type BoltdbProvider
- type DataType
- type File
- type FileType
- type Flusher
- type Getter
- type Kind
- type Option
- type Store
- func (s *Store) Flush(key string) error
- func (s *Store) Int32(k string) int32
- func (s *Store) Load(file string, ft FileType, dt DataType, rootKeys ...string) error
- func (s *Store) MergeStore(store *Store) error
- func (s *Store) SetDefault(k string, v any)
- func (s *Store) Uint(key string) uint
- func (s *Store) Uint16(key string) uint16
- func (s *Store) Uint32(key string) uint32
- func (s *Store) Uint64(key string) uint64
- func (s *Store) UnmarshalKey(path string, o any) error
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Clamp ¶ added in v0.2.0
Clamp overwrites value of key to min or max if its value is not within range [min, max].
func ClampDefault ¶ added in v0.2.0
ClampDefault acts the same as Clamp except that value of key is overwritten by the default value other than the boundary.
func LoadJsonConfig ¶
LoadJsonConfig loads config object of a JSON file and deserialize to the given object. Return nil or any error if happened during loading and unmarshal.
func MergeStore ¶ added in v0.3.0
MergeStore merges the given store into the global one.
func Uint16 ¶ added in v0.3.0
Uint16 returns the value associated with the key as an unsigned integer.
func Uint32 ¶ added in v0.3.0
Uint32 returns the value associated with the key as an unsigned integer.
func Uint64 ¶ added in v0.3.0
Uint64 returns the value associated with the key as an unsigned integer.
func UnmarshalKey ¶ added in v0.3.0
Types ¶
type BoltdbProvider ¶ added in v0.3.0
type BoltdbProvider struct {
// contains filtered or unexported fields
}
BoltdbProvider implements a boltdb provider. To use the provider correctly, a concrete parser is needed to parse raw bytes returned by ReadBytes.
func NewBoltdbProvider ¶ added in v0.3.0
func NewBoltdbProvider(path string) *BoltdbProvider
NewBoltdbProvider returns a boltdb provider.
func (*BoltdbProvider) Read ¶ added in v0.3.0
func (f *BoltdbProvider) Read() (map[string]any, error)
Read is not supported by boltdb provider.
func (*BoltdbProvider) ReadBytes ¶ added in v0.3.0
func (f *BoltdbProvider) ReadBytes() ([]byte, error)
ReadBytes is not supported by boltdb provider.
type Store ¶ added in v0.2.0
type Store struct { //*viper.Viper *koanf.Koanf // contains filtered or unexported fields }
Store wraps viper and provides extended functionalities. Store uses a storage system as the backlog and accepts multiple config sources to merge them into the storage.
A config store is structured as a tree and be flattened using a key-value pattern, and the config value is accessed using a key, depicted by a tree-node-path.
func New ¶ added in v0.2.0
New creates a configuration store. Returns the created store or nil if any error occurred.
func SubStore ¶ added in v0.3.0
SubStore returns a copy of the subtree of the global store. The subtree is identified by the given path.
func (*Store) Load ¶ added in v0.2.0
Load loads config from file into this store. When called multiple times over different files, configs are merged.
func (*Store) MergeStore ¶ added in v0.3.0
func (*Store) SetDefault ¶ added in v0.3.0
SetDefault is here for compatible with viper api.