config

package
v1.3.164 Latest Latest
Warning

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

Go to latest
Published: Aug 1, 2024 License: GPL-3.0 Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Config

type Config struct {
	*config.Config
	// contains filtered or unexported fields
}

func NewConfig added in v0.5.7

func NewConfig(appName, mode, localConfigFolder string) (*Config, error)

func (*Config) GetFolderPath

func (c *Config) GetFolderPath() string

type IConfig added in v0.5.7

type IConfig interface {
	Get(key string, findByPath ...bool) (value interface{}, ok bool)
	String(key string) (value string, ok bool)
	DefString(key string, defVal ...string) string
	MustString(key string) string

	Int(key string) (value int, ok bool)
	DefInt(key string, defVal ...int) int
	MustInt(key string) int
	Int64(key string) (value int64, ok bool)
	DefInt64(key string, defVal ...int64) int64
	MustInt64(key string) int64
	// Bool looks up a value for a key in this section and attempts to parse that value as a boolean,
	// along with a boolean result similar to a map lookup.
	// of following(case insensitive):
	//  - true
	//  - yes
	//  - false
	//  - no
	//  - 1
	//  - 0
	// The `ok` boolean will be false in the event that the value could not be parsed as a bool
	Bool(key string) (value bool, ok bool)
	DefBool(key string, defVal ...bool) bool
	MustBool(key string) bool

	Float(key string) (value float64, ok bool)
	DefFloat(key string, defVal ...float64) float64

	Ints(key string) (arr []int, ok bool)
	IntMap(key string) (mp map[string]int, ok bool)

	Strings(key string) (arr []string, ok bool)
	StringMap(key string) (mp map[string]string, ok bool)

	MapStruct(key string, v interface{}) (err error)
	MapStructure(key string, v interface{}) (err error)

	// Structure get config data and map to a structure.
	// usage:
	// 	dbInfo := Db{}
	// 	config.Structure("db", &dbInfo)
	Structure(key string, v interface{}) (err error)

	// IsEmpty of the config
	IsEmpty() bool
	GetFolderPath() string
}

Jump to

Keyboard shortcuts

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