Пример #1
0
// AsFloat should get value from path or return val.
func (am ArgMap) AsFloat(aliases ...string) float64 {
	for _, key := range aliases {
		f, err := to.Float64(am[key])
		if err == nil {
			return f
		}
	}
	return 0
}
Пример #2
0
// MayFloat should get value from path or return val.
func (am ArgMap) MayFloat(defaultValue float64, aliases ...string) float64 {
	for _, key := range aliases {
		f, err := to.Float64(am[key])
		if err == nil {
			return f
		}
	}
	return defaultValue
}
Пример #3
0
// MustFloat should get value from path or return val.
func (am ArgMap) MustFloat(aliases ...string) float64 {
	for _, key := range aliases {
		f, err := to.Float64(am[key])
		if err == nil {
			return f
		}
	}
	panic(fmt.Sprintf("None of these flags were found or convertable to float64: %v", aliases))
}