config

package module
v0.0.2 Latest Latest
Warning

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

Go to latest
Published: Oct 31, 2022 License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

Index

Constants

View Source
const (
	WriteOrCreateMask  = fsnotify.Write | fsnotify.Create
	RenameOrRemoveMask = fsnotify.Rename | fsnotify.Remove
)

Variables

This section is empty.

Functions

This section is empty.

Types

type CfgManager

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

func New

func New(loader Loader, filePath string, options ...Option) *CfgManager

func (*CfgManager) ReadConfig

func (m *CfgManager) ReadConfig(v interface{}) error

type Loader

type Loader interface {
	Load(path string, v interface{}) error
	Save(path string, v interface{}) error
}

type Option

type Option func(m *CfgManager)

func CreateIfNotExists

func CreateIfNotExists(v bool) Option

func KeyDelim

func KeyDelim(delim string) Option

must set before WithDefaultConfig and WithDefaultConfigs

func OnConfigChange

func OnConfigChange(f func(fsnotify.Event)) Option

file change event

func WatchConfigFile

func WatchConfigFile(v bool) Option

watch config changes,default:true

func WithDefaultConfig

func WithDefaultConfig(k string, v interface{}) Option

override configuration in v

func WithDefaultConfigs

func WithDefaultConfigs(configs map[string]interface{}) Option

override configuration in v

Jump to

Keyboard shortcuts

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