Documentation
¶
Index ¶
- func ConvertTo[T configtype](val any) T
- func Get[T configtype](c *Configuration, key string) T
- type Configuration
- func (c *Configuration) Delete(key string)
- func (c *Configuration) Exists(key string) bool
- func (c *Configuration) Get(key string) (any, bool)
- func (c *Configuration) GetBool(key string) bool
- func (c *Configuration) GetFloat64(key string) float64
- func (c *Configuration) GetInt(key string) int
- func (c *Configuration) GetInt64(key string) int64
- func (c *Configuration) GetStr(key string) string
- func (c *Configuration) Set(key string, val any)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ConvertTo ¶
func ConvertTo[T configtype](val any) T
ConvertTo converts a value to the specified type.
func Get ¶
func Get[T configtype](c *Configuration, key string) T
Get retrieves a value from the configuration by key and converts it to the specified type.
Types ¶
type Configuration ¶
type Configuration struct {
// contains filtered or unexported fields
}
Configuration holds the Configuration key-value pairs and provides thread-safe access.
func ReadFile ¶
func ReadFile(fname string) *Configuration
ReadFile reads a JSON configuration file and updates the global configuration.
func (*Configuration) Delete ¶
func (c *Configuration) Delete(key string)
Delete removes a key from the configuration.
func (*Configuration) Exists ¶
func (c *Configuration) Exists(key string) bool
Exists checks if a key exists in the configuration.
func (*Configuration) Get ¶
func (c *Configuration) Get(key string) (any, bool)
Get retrieves a value from the configuration by key.
func (*Configuration) GetBool ¶
func (c *Configuration) GetBool(key string) bool
GetBool retrieves a bool value from the configuration by key.
func (*Configuration) GetFloat64 ¶
func (c *Configuration) GetFloat64(key string) float64
GetFloat64 retrieves a float64 value from the configuration by key.
func (*Configuration) GetInt ¶
func (c *Configuration) GetInt(key string) int
GetInt retrieves an int value from the configuration by key.
func (*Configuration) GetInt64 ¶
func (c *Configuration) GetInt64(key string) int64
GetInt64 retrieves an int64 value from the configuration by key.
func (*Configuration) GetStr ¶
func (c *Configuration) GetStr(key string) string
GetStr retrieves a string value from the configuration by key.
func (*Configuration) Set ¶
func (c *Configuration) Set(key string, val any)
Set sets a value in the configuration by key.