示例#1
0
// all unsigned int64 are also stored int64... unless overflowed...
func (this Configuration) Uint64(key string, def ...uint64) (res uint64) {
	if len(def) > 0 {
		res = def[0]
	}

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

	return
}
示例#2
0
func (this Configuration) Uint64Slice(key string, def ...[]uint64) (res []uint64) {
	if len(def) > 0 {
		res = def[0]
	}

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

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

		res = sl
	}

	return
}
示例#3
0
func (this Configuration) Uint32Slice(key string, def ...[]uint32) (res []uint32) {
	if len(def) > 0 {
		res = def[0]
	}

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

		for i, val := range v {
			if tuint64, err := util.CastUint64(val); err == nil {
				sl[i] = uint32(tuint64)
			} else {
				return
			}
		}

		res = sl
	}

	return
}