Documentation ¶
Index ¶
- Constants
- func Expand(path string) (string, error)
- func ExpandValueEnv(s string) string
- func ExpandValueEnvForMap(m map[string]interface{}) map[string]interface{}
- func HomeDir() (string, error)
- func IsBigEndian() bool
- func Register(name string, adapter Config)
- type Config
- type Configor
- type JSONConfig
- type JSONObject
- func (jo *JSONObject) GetBool(key string) (bool, error)
- func (jo *JSONObject) GetFloat(key string, defaultVal ...float64) (float64, error)
- func (jo *JSONObject) GetInt(key string, defaultVal ...int) (int, error)
- func (jo *JSONObject) GetInt64(key string, defaultVal ...int64) (int64, error)
- func (jo *JSONObject) GetRawValue(key string) (interface{}, error)
- func (jo *JSONObject) GetString(key string, defaultVal ...string) string
- func (jo *JSONObject) SaveFile(file string) error
- func (jo *JSONObject) SetString(key, val string) error
- type YAMLConfig
- type YAMLObject
- func (yo *YAMLObject) GetBool(key string) (bool, error)
- func (yo *YAMLObject) GetFloat(key string, defaultVal ...float64) (float64, error)
- func (yo *YAMLObject) GetInt(key string, defaultVal ...int) (int, error)
- func (yo *YAMLObject) GetInt64(key string, defaultVal ...int64) (int64, error)
- func (yo *YAMLObject) GetRawValue(key string) (interface{}, error)
- func (yo *YAMLObject) GetString(key string, defaultVal ...string) string
- func (yo *YAMLObject) SaveFile(file string) error
- func (yo *YAMLObject) SetString(key, val string) error
Constants ¶
View Source
const INT_SIZE int = int(unsafe.Sizeof(0))
Variables ¶
This section is empty.
Functions ¶
func Expand ¶
Expand expands the path to include the home directory if the path is prefixed with `~`. If it isn't prefixed with `~`, the path is returned as-is.
func ExpandValueEnv ¶
ExpandValueEnv returns value of convert with environment variable. Return default value if environment variable is empty or not exist. Must begin with $.
It accept value formats "$env" , "${env}" , "${env||defaultValue}". Examples:
v1 := config.ExpandValueEnv("$the result: $GOPATH") // return the GOPATH environment variable. v2 := config.ExpandValueEnv("$the result: ${GOPATH}") // return the GOPATH environment variable. v3 := config.ExpandValueEnv("$the result: ${GOPATHX||/usr/local/go}") // return the default value "/usr/local/go/".
func ExpandValueEnvForMap ¶
ExpandValueEnvForMap convert all string value with environment variable.
Types ¶
type Configor ¶
type Configor interface { SetString(key, val string) error GetString(key string, defaultVal ...string) string GetInt(key string, defaultVal ...int) (int, error) GetInt64(key string, defaultVal ...int64) (int64, error) GetBool(key string) (bool, error) GetFloat(key string, defaultVal ...float64) (float64, error) GetRawValue(key string) (interface{}, error) SaveFile(file string) error }
type JSONConfig ¶
type JSONConfig struct { }
type JSONObject ¶
func (*JSONObject) GetFloat ¶
func (jo *JSONObject) GetFloat(key string, defaultVal ...float64) (float64, error)
func (*JSONObject) GetInt ¶
func (jo *JSONObject) GetInt(key string, defaultVal ...int) (int, error)
func (*JSONObject) GetInt64 ¶
func (jo *JSONObject) GetInt64(key string, defaultVal ...int64) (int64, error)
func (*JSONObject) GetRawValue ¶
func (jo *JSONObject) GetRawValue(key string) (interface{}, error)
func (*JSONObject) GetString ¶
func (jo *JSONObject) GetString(key string, defaultVal ...string) string
func (*JSONObject) SaveFile ¶
func (jo *JSONObject) SaveFile(file string) error
func (*JSONObject) SetString ¶
func (jo *JSONObject) SetString(key, val string) error
type YAMLConfig ¶
type YAMLConfig struct { }
type YAMLObject ¶
func (*YAMLObject) GetFloat ¶
func (yo *YAMLObject) GetFloat(key string, defaultVal ...float64) (float64, error)
func (*YAMLObject) GetInt ¶
func (yo *YAMLObject) GetInt(key string, defaultVal ...int) (int, error)
func (*YAMLObject) GetInt64 ¶
func (yo *YAMLObject) GetInt64(key string, defaultVal ...int64) (int64, error)
func (*YAMLObject) GetRawValue ¶
func (yo *YAMLObject) GetRawValue(key string) (interface{}, error)
func (*YAMLObject) GetString ¶
func (yo *YAMLObject) GetString(key string, defaultVal ...string) string
func (*YAMLObject) SaveFile ¶
func (yo *YAMLObject) SaveFile(file string) error
func (*YAMLObject) SetString ¶
func (yo *YAMLObject) SetString(key, val string) error
Click to show internal directories.
Click to hide internal directories.