示例#1
0
文件: schema.go 项目: sguzwf/vertex
func intTag(f reflect.StructField, tag string, deflt int) (int, bool) {

	var err error
	var ret int64

	v := f.Tag.Get(tag)
	if v == "" {
		return deflt, false
	}

	if ret, err = strconv.ParseInt(v, 10, 64); err != nil {
		logging.Panic("Invalid value for int: %s", v)
	}
	return int(ret), true

}
示例#2
0
文件: schema.go 项目: sguzwf/vertex
func floatTag(f reflect.StructField, tag string, deflt float64) (float64, bool) {

	var err error
	var ret float64

	v := f.Tag.Get(tag)
	if v == "" {
		return deflt, false
	}

	if ret, err = strconv.ParseFloat(v, 64); err != nil {
		logging.Panic("Invalid value for float: %s", v)
	}

	return ret, true

}