Пример #1
0
func (c *Configuration) Int(lookup string) (int, error) {
	if v, err := c.get(lookup); err != nil {
		return -1, err
	} else {
		if i, err := reflect.Coerse(v, reflect.Int); err != nil {
			return -1, err
		} else {
			return i.(int), nil
		}
	}
}
Пример #2
0
func (c *Configuration) Bool(lookup string) (bool, error) {
	if v, err := c.get(lookup); err != nil {
		return false, err
	} else {
		if b, err := reflect.Coerse(v, reflect.Bool); err != nil {
			return false, err
		} else {
			return b.(bool), nil
		}
	}
}
Пример #3
0
func (c *Configuration) String(lookup string) (string, error) {
	if v, err := c.get(lookup); err != nil {
		return "", err
	} else {
		if s, err := reflect.Coerse(v, reflect.String); err != nil {
			return "", err
		} else {
			return s.(string), nil
		}
	}
}