config

package
v0.3.1 Latest Latest
Warning

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

Go to latest
Published: Nov 21, 2023 License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

Index

Constants

View Source
const (
	DefaultConfigType = "json"
)

Variables

View Source
var (
	// ConfigName holds the name of the configuration file.
	ConfigName = ""

	// ConfigType specifies the type/format of the configuration file.
	ConfigType = ""

	// ConfigPath denotes the path to the configuration file.
	ConfigPath = ""
)
View Source
var DefaultTag string

DefaultTag is the default tag used to identify default values for struct fields.

Functions

func GetConfig

func GetConfig() map[string]interface{}

GetConfig retrieves all configuration settings as a map.

func Init

func Init(name, _type, path string) error

Init initializes the configuration settings. It sets up the name, type, and path for the configuration file.

func Load

func Load(conf interface{}) error

Load loads the configuration from the previously initialized file. It unmarshals the configuration into the provided conf interface.

func LoadFile

func LoadFile(file string, conf interface{}) error

LoadFile loads the configuration from a specified file. It unmarshals the configuration into the provided conf interface.

func ResetConfig

func ResetConfig() error

ResetConfig resets the configuration to empty.

func SetConfig

func SetConfig(key string, value interface{}) error

SetConfig sets a configuration key to a specified value. It also writes the updated configuration back to the file.

func SetDefault

func SetDefault(v interface{})

SetDefault sets the default values for a given interface{}. The interface{} must be a pointer to a struct, bcs the default values are SET on the struct fields.

func SetDefaultTag

func SetDefaultTag(tag string)

SetDefaultTag updates the tag used to identify default values.

Types

This section is empty.

Jump to

Keyboard shortcuts

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