config

package
v1.0.2 Latest Latest
Warning

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

Go to latest
Published: Aug 11, 2021 License: Apache-2.0 Imports: 10 Imported by: 5

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ParseBool

func ParseBool(val interface{}) (value bool, err error)

ParseBool accepts 1, 1.0, t, T, TRUE, true, True, YES, yes, Yes,Y, y, ON, on, On, 0, 0.0, f, F, FALSE, false, False, NO, no, No, N,n, OFF, off, Off. Any other value returns an error.

Types

type Config

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

func NewConfig

func NewConfig() *Config

func NewConfigFromFile

func NewConfigFromFile(path string) (*Config, error)

NewConfigFromFile parse config from file.

func NewConfigFromReader

func NewConfigFromReader(r io.Reader) (*Config, error)

NewConfigFromReader parse config from a reader

func (*Config) Bool

func (c *Config) Bool(key string) (bool, error)

Bool returns the boolean value for a given key.

func (*Config) DIY

func (c *Config) DIY(key string) (v interface{}, err error)

DIY returns the raw value by a given key.

func (*Config) DefaultInt

func (c *Config) DefaultInt(key string, defaultval int) int

DefaultInt returns the integer value for a given key. if err != nil return defaltval

func (*Config) GetOriginMap

func (c *Config) GetOriginMap() map[interface{}]interface{}

GetOriginMap : get origin configs map

func (*Config) GetSection

func (c *Config) GetSection(key string) (map[interface{}]interface{}, error)

GetSection returns map for the given key

func (*Config) GetStruct

func (c *Config) GetStruct(key string, out interface{}) error

GetStruct returns struct for the give key and given struct type

func (*Config) Int

func (c *Config) Int(key string) (int, error)

Int returns the integer value for a given key.

func (*Config) Int64

func (c *Config) Int64(key string) (int64, error)

Int64 returns the int64 value for a given key.

func (*Config) Merge

func (c *Config) Merge(config *Config)

func (*Config) ReplacePlaceHolder

func (c *Config) ReplacePlaceHolder(placeHolders map[string]interface{})

ReplacePlaceHolder will replace all palceholders like '${key}', replace 'key' to 'value' according to the properties map.

func (*Config) String

func (c *Config) String(key string) string

String returns the string value for a given key.

Jump to

Keyboard shortcuts

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