config

package module
v0.0.0-...-65df8d3 Latest Latest
Warning

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

Go to latest
Published: Jun 8, 2018 License: MIT Imports: 5 Imported by: 15

README

config

Documentation

Index

Constants

This section is empty.

Variables

View Source
var GlobalConfig = config

GlobalConfig global builtin config

Functions

func GetBool

func GetBool(path string, defaultval bool) bool

GetBool get config value as bool

func GetDuration

func GetDuration(path string, defaultval time.Duration) time.Duration

GetDuration get config value as Int

func GetInt64

func GetInt64(path string, defaultval int64) int64

GetInt64 get config value as Int

func GetObject

func GetObject(path string, v interface{}) error

GetObject get config value as object

func GetString

func GetString(path string, defaultval string) string

GetString get config value as String

func Has

func Has(path string) bool

Has global method, check if global config object has the config item

func Load

func Load(source []byte)

Load load config from source bytes

func LoadFromFile

func LoadFromFile(filepath string) error

LoadFromFile load config from config json file

Types

type Config

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

Config golang json config object

func New

func New(source []byte) (*Config, error)

New load config from json bytes

func NewFromFile

func NewFromFile(filepath string) (*Config, error)

NewFromFile load config from json file

func (*Config) Get

func (config *Config) Get(path string) Value

Get get config value

func (*Config) GetBool

func (config *Config) GetBool(path string, defaultval bool) bool

GetBool get config value as bool

func (*Config) GetConfig

func (config *Config) GetConfig(path string) *Config

GetConfig get sub config

func (*Config) GetDuration

func (config *Config) GetDuration(path string, defaultval time.Duration) time.Duration

GetDuration fetch config value as time.Duration

func (*Config) GetInt64

func (config *Config) GetInt64(path string, defaultval int64) int64

GetInt64 get config value as Int

func (*Config) GetObject

func (config *Config) GetObject(path string, v interface{}) error

GetObject get config value as object

func (*Config) GetString

func (config *Config) GetString(path string, defaultval string) string

GetString get config value as Int

func (*Config) Has

func (config *Config) Has(path string) bool

Has check if has config item indicate by path

func (*Config) Reload

func (config *Config) Reload(source []byte) error

Reload reload config from source bytes

func (*Config) String

func (config *Config) String() string

String print config as string

type Value

type Value interface{}

Value config item value

func Get

func Get(path string) Value

Get global method, get config value from global config object

Jump to

Keyboard shortcuts

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