Ejemplo n.º 1
0
func (this Configuration) Float64(key string, def ...float64) (res float64) {
	if len(def) > 0 {
		res = def[0]
	}

	if tfloat64, err := util.CastFloat64(this.Interface(key, def)); err == nil {
		res = tfloat64
	}

	return
}
Ejemplo n.º 2
0
func (this Configuration) Float64Slice(key string, def ...[]float64) (res []float64) {
	if len(def) > 0 {
		res = def[0]
	}

	if v := this.Slice(key, nil); v != nil {
		sl := make([]float64, len(v))

		var err error
		for i, val := range v {
			if sl[i], err = util.CastFloat64(val); err != nil {
				return
			}
		}

		res = sl
	}

	return
}
Ejemplo n.º 3
0
func (this Configuration) Float32Slice(key string, def ...[]float32) (res []float32) {
	if len(def) > 0 {
		res = def[0]
	}

	if v := this.Slice(key, nil); v != nil {
		sl := make([]float32, len(v))

		for i, val := range v {
			if tfloat64, err := util.CastFloat64(val); err == nil {
				sl[i] = float32(tfloat64)
			} else {
				return
			}
		}

		res = sl
	}

	return
}