conf

package
v0.1.4 Latest Latest
Warning

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

Go to latest
Published: Dec 28, 2023 License: BSD-2-Clause Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Exists

func Exists(key string) bool

Exists returns whether key exists

func Flush

func Flush() error

Flush conf to file

func Get

func Get(key string) interface{}

Get returns an interface. For a specific value use one of the Get____ methods.

func GetInt

func GetInt(key string) int

GetInt returns the value associated with the key as an integer with default defaultConfiguration.

func GetInt64 added in v0.1.4

func GetInt64(key string) int64

GetInt returns the value associated with the key as an integer with default defaultConfiguration.

func GetString

func GetString(key string) string

GetString returns the value associated with the key as a string with default defaultConfiguration.

func GetStringMap

func GetStringMap(key string) map[string]interface{}

GetStringMap returns the value associated with the key as a map of interfaces with default defaultConfiguration.

func Load

func Load(filepath string) error

LoadFromDataSource load configuration from data source if data source supports dynamic config, a monitor goroutinue would be

func OnChange

func OnChange(fn func(*Configuration))

TODO: 未实现 OnChange 注册change回调函数

func OnLoaded

func OnLoaded(fn func(*Configuration))

func Reset

func Reset()

Reset resets all to default settings.

func Set

func Set(key string, val interface{})

Set set config value for key

Types

type Configuration

type Configuration struct {
	// contains filtered or unexported fields
}

func New

func New() *Configuration

New constructs a new Configuration with provider.

func (*Configuration) Flush

func (c *Configuration) Flush() error

Flush ...

func (*Configuration) Load

func (c *Configuration) Load(filepath string) error

func (*Configuration) OnChange

func (c *Configuration) OnChange(fn func(*Configuration))

OnChange 注册change回调函数 TODO: 未实现

func (*Configuration) OnLoaded

func (c *Configuration) OnLoaded(fn func(*Configuration))

Jump to

Keyboard shortcuts

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