Exemplo n.º 1
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
}
Exemplo n.º 2
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))
}
Exemplo n.º 3
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
}