diff --git a/filter.go b/filter.go index 1194985..3c2b6a8 100644 --- a/filter.go +++ b/filter.go @@ -184,57 +184,37 @@ func (f *filter) getValue(dataType string, sourceValue gjson.Result, defaultValu switch dataType { case DataTypeInt8: - fallthrough + return util.StringConvert.ToInt8(sourceValueStr) case DataTypeInt16: - fallthrough + return util.StringConvert.ToInt16(sourceValueStr) case DataTypeInt32: - fallthrough + return util.StringConvert.ToInt32(sourceValueStr) case DataTypeInt64: - fallthrough + return util.StringConvert.ToInt64(sourceValueStr) case DataTypeInt: - var ( - err error - val int64 - ) - err = util.ConvertAssign(&val, sourceValueStr) - return val, err + return util.StringConvert.ToInt(sourceValueStr) case DataTypeUint8: - fallthrough + return util.StringConvert.ToUint8(sourceValueStr) case DataTypeUint16: - fallthrough + return util.StringConvert.ToUint16(sourceValueStr) case DataTypeUint32: - fallthrough + return util.StringConvert.ToUint32(sourceValueStr) case DataTypeUint64: - fallthrough + return util.StringConvert.ToUint64(sourceValueStr) case DataTypeUint: - var ( - err error - val uint64 - ) - err = util.ConvertAssign(&val, sourceValueStr) - return val, err + return util.StringConvert.ToUint(sourceValueStr) case DataTypeBool: - var ( - err error - val bool - ) - err = util.ConvertAssign(&val, sourceValueStr) - return val, err + return util.StringConvert.ToBool(sourceValueStr) case DataTypeFloat32: - fallthrough + return util.StringConvert.ToFloat32(sourceValueStr) case DataTypeFloat64: - fallthrough + return util.StringConvert.ToFloat64(sourceValueStr) case DataTypeFloat: - fallthrough + return util.StringConvert.ToFloat64(sourceValueStr) case DataTypeDouble: - fallthrough + return util.StringConvert.ToDouble(sourceValueStr) case DataTypeNumber: - var ( - err error - val float64 - ) - err = util.ConvertAssign(&val, sourceValueStr) - return val, err + return util.StringConvert.ToNumber(sourceValueStr) case DataTypeString: return sourceValueStr, nil case DataTypeAny: diff --git a/go.mod b/go.mod index eeb28e4..c3b6d01 100644 --- a/go.mod +++ b/go.mod @@ -4,7 +4,7 @@ go 1.18 require ( git.zhangdeman.cn/zhangdeman/easylock v0.0.0-20220627070212-c590a0a1c216 - git.zhangdeman.cn/zhangdeman/util v0.0.0-20230330082619-662152cb682d + git.zhangdeman.cn/zhangdeman/util v0.0.0-20230505025924-96532aff0019 github.com/Jeffail/gabs v1.4.0 github.com/pkg/errors v0.9.1 github.com/smartystreets/goconvey v1.7.2 @@ -19,6 +19,8 @@ require ( github.com/go-ini/ini v1.67.0 // indirect github.com/gopherjs/gopherjs v0.0.0-20181017120253-0766667cb4d1 // indirect github.com/jtolds/gls v4.20.0+incompatible // indirect + github.com/mitchellh/go-homedir v1.1.0 // indirect + github.com/mssola/user_agent v0.6.0 // indirect github.com/pmezard/go-difflib v1.0.0 // indirect github.com/smartystreets/assertions v1.2.0 // indirect github.com/spaolacci/murmur3 v1.1.0 // indirect diff --git a/go.sum b/go.sum index fc1eeab..571448e 100644 --- a/go.sum +++ b/go.sum @@ -7,6 +7,8 @@ git.zhangdeman.cn/zhangdeman/util v0.0.0-20230330065032-faba0a5a9ea1 h1:u2FdNfcG git.zhangdeman.cn/zhangdeman/util v0.0.0-20230330065032-faba0a5a9ea1/go.mod h1:SyRTkOz6gxUVn3S/Qtkf+rhKV0I1ym8lwsT8YjggYFs= git.zhangdeman.cn/zhangdeman/util v0.0.0-20230330082619-662152cb682d h1:kMQZmkYBceHM3O7wiCelSADjTyOF3EBxXTX8fgZA+6c= git.zhangdeman.cn/zhangdeman/util v0.0.0-20230330082619-662152cb682d/go.mod h1:qeVsrMae8ljqzcsmI+lWPU/4Rdjb9cOt4oaDUNEf1Ck= +git.zhangdeman.cn/zhangdeman/util v0.0.0-20230505025924-96532aff0019 h1:eJ/9rEj2iI8P9I1DfCmMUvsV+n2EiAWCXnI9yVVDHO0= +git.zhangdeman.cn/zhangdeman/util v0.0.0-20230505025924-96532aff0019/go.mod h1:z2bP5LIwRVpWSQV0/a3WIFaoarJUP8kA/0Clv0bP+8I= github.com/Jeffail/gabs v1.4.0 h1://5fYRRTq1edjfIrQGvdkcd22pkYUrHZ5YC/H2GJVAo= github.com/Jeffail/gabs v1.4.0/go.mod h1:6xMvQMK4k33lb7GUUpaAPh6nKMmemQeg5d4gn7/bOXc= github.com/axgle/mahonia v0.0.0-20180208002826-3358181d7394 h1:OYA+5W64v3OgClL+IrOD63t4i/RW7RqrAVl9LTZ9UqQ= @@ -22,6 +24,10 @@ github.com/gopherjs/gopherjs v0.0.0-20181017120253-0766667cb4d1 h1:EGx4pi6eqNxGa github.com/gopherjs/gopherjs v0.0.0-20181017120253-0766667cb4d1/go.mod h1:wJfORRmW1u3UXTncJ5qlYoELFm8eSnnEO6hX4iZ3EWY= github.com/jtolds/gls v4.20.0+incompatible h1:xdiiI2gbIgH/gLH7ADydsJ1uDOEzR8yvV7C0MuV77Wo= github.com/jtolds/gls v4.20.0+incompatible/go.mod h1:QJZ7F/aHp+rZTRtaJ1ow/lLfFfVYBRgL+9YlvaHOwJU= +github.com/mitchellh/go-homedir v1.1.0 h1:lukF9ziXFxDFPkA1vsr5zpc1XuPDn/wFntq5mG+4E0Y= +github.com/mitchellh/go-homedir v1.1.0/go.mod h1:SfyaCUpYCn1Vlf4IUYiD9fPX4A5wJrkLzIz1N1q0pr0= +github.com/mssola/user_agent v0.6.0 h1:uwPR4rtWlCHRFyyP9u2KOV0u8iQXmS7Z7feTrstQwk4= +github.com/mssola/user_agent v0.6.0/go.mod h1:TTPno8LPY3wAIEKRpAtkdMT0f8SE24pLRGPahjCH4uw= github.com/pkg/errors v0.9.1 h1:FEBLx1zS214owpjy7qsBeixbURkuhQAwrK5UwLGTwt4= github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=