config

package module
v0.0.0-...-6d8566b Latest Latest
Warning

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

Go to latest
Published: Nov 17, 2018 License: Apache-2.0 Imports: 7 Imported by: 2

README

config GoDoc

Library to read APIBox config file.

See full document at: https://go-apibox.github.io/docs/#!other/config.md (Chinese)

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Config

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

func FromFile

func FromFile(configFile string) (*Config, error)

FromFile create a config with specified config file.

func FromString

func FromString(yamlStr string) (*Config, error)

FromString create a config by specified yaml string.

func (*Config) Get

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

Get returns the interface{} value for a given key. Support multi-level key which concat with '.'.

func (*Config) GetBool

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

GetBool returns the boolean value for a given key.

func (*Config) GetBoolArray

func (c *Config) GetBoolArray(key string) ([]bool, error)

GetBoolArray returns the []bool value for a given key.

func (*Config) GetDefaultBool

func (c *Config) GetDefaultBool(key string, defaultVal bool) bool

GetDefaultBool returns the boolean value for a given key. if error occur, return defaultVal

func (*Config) GetDefaultBoolArray

func (c *Config) GetDefaultBoolArray(key string, defaultVal []bool) []bool

GetDefaultBoolArray returns the []bool value for a given key. if error occur, return defaultVal

func (*Config) GetDefaultFloat

func (c *Config) GetDefaultFloat(key string, defaultVal float64) float64

GetDefaultFloat returns the float64 value for a given key. if error occur, return defaultVal

func (*Config) GetDefaultFloatArray

func (c *Config) GetDefaultFloatArray(key string, defaultVal []float64) []float64

GetDefaultFloatArray returns the []float64 value for a given key. if error occur, return defaultVal

func (*Config) GetDefaultInt

func (c *Config) GetDefaultInt(key string, defaultVal int) int

GetDefaultInt returns the int value for a given key. if error occur, return defaultVal

func (*Config) GetDefaultIntArray

func (c *Config) GetDefaultIntArray(key string, defaultVal []int) []int

GetDefaultIntArray returns the []int value for a given key. if error occur, return defaultVal

func (*Config) GetDefaultMap

func (c *Config) GetDefaultMap(key string, defaultVal map[string]interface{}) map[string]interface{}

GetDefaultMap returns the map[string]interface{} value for a given key. if error occur, return defaultVal

func (*Config) GetDefaultString

func (c *Config) GetDefaultString(key string, defaultVal string) string

GetDefaultString returns the string value for a given key. if error occur, return defaultVal

func (*Config) GetDefaultStringArray

func (c *Config) GetDefaultStringArray(key string, defaultVal []string) []string

GetDefaultStringArray returns the []string value for a given key. if error occur, return defaultVal

func (*Config) GetFloat

func (c *Config) GetFloat(key string) (float64, error)

GetFloat returns the float64 value for a given key.

func (*Config) GetFloatArray

func (c *Config) GetFloatArray(key string) ([]float64, error)

GetFloatArray returns the []float64 value for a given key.

func (*Config) GetInt

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

GetInt returns the int value for a given key.

func (*Config) GetIntArray

func (c *Config) GetIntArray(key string) ([]int, error)

GetIntArray returns the []int value for a given key.

func (*Config) GetMap

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

GetMap returns the map[string]interface{} value for a given key.

func (*Config) GetString

func (c *Config) GetString(key string) (string, error)

GetString returns the string value for a given key.

func (*Config) GetStringArray

func (c *Config) GetStringArray(key string) ([]string, error)

GetStringArray returns the []string value for a given key.

func (*Config) GetSubKeys

func (c *Config) GetSubKeys(key string) ([]string, error)

GetSubKeys returns the subkey array of a given key. Support multi-level key which concat with '.'.

func (*Config) Len

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

Len returns the value length of a given key. Support multi-level key which concat with '.'.

Jump to

Keyboard shortcuts

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