config

package module
v0.0.0-...-d0dc385 Latest Latest
Warning

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

Go to latest
Published: Jan 14, 2025 License: MIT Imports: 6 Imported by: 0

Documentation

Index

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 Config

func Config() *Configuration

Config returns the global configuration instance.

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.

Jump to

Keyboard shortcuts

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