@@ -48,6 +48,8 @@ func toBytes(i interface{}) []byte {
48
48
}
49
49
}
50
50
return toBytes (result )
51
+ case * Var :
52
+ return toBytes (value .Val ())
51
53
}
52
54
if IsNumber (i ) {
53
55
// int 类型无法解析
@@ -116,6 +118,8 @@ func toString(i interface{}) string {
116
118
case io.Reader :
117
119
bs , _ := ioutil .ReadAll (value )
118
120
return string (bs )
121
+ case * Var :
122
+ return toString (value .Val ())
119
123
default :
120
124
if value == nil {
121
125
return ""
@@ -204,6 +208,8 @@ func toInt64(i interface{}) int64 {
204
208
return int64 (value .Int ())
205
209
case apiInt64 :
206
210
return value .Int64 ()
211
+ case * Var :
212
+ return toInt64 (value .Val ())
207
213
default :
208
214
s := toString (value )
209
215
base := int64 (1 )
@@ -291,6 +297,8 @@ func toUint64(i interface{}) uint64 {
291
297
return uint64 (value .Uint ())
292
298
case apiUint64 :
293
299
return value .Uint64 ()
300
+ case * Var :
301
+ return toUint64 (value .Val ())
294
302
default :
295
303
s := toString (value )
296
304
// HEX 十六进制
@@ -339,6 +347,8 @@ func toFloat64(i interface{}) float64 {
339
347
return toFloat64 (math .Float32frombits (binary .BigEndian .Uint32 (padding (value , 4 ))))
340
348
}
341
349
return math .Float64frombits (binary .BigEndian .Uint64 (padding (value , 8 )))
350
+ case * Var :
351
+ return toFloat64 (value .Val ())
342
352
default :
343
353
v , _ := strconv .ParseFloat (toString (i ), 64 )
344
354
return v
@@ -357,6 +367,8 @@ func toBool(i interface{}) bool {
357
367
return emptyMap [strings .ToLower (toString (value ))] == nil
358
368
case apiBool :
359
369
return value .Bool ()
370
+ case * Var :
371
+ return toBool (value .Val ())
360
372
default :
361
373
rv := reflect .ValueOf (i )
362
374
switch rv .Kind () {
@@ -457,6 +469,13 @@ func toInterfaces(i interface{}) []interface{} {
457
469
}
458
470
case apiInterfaces :
459
471
return value .Interfaces ()
472
+ case * Var :
473
+ return []interface {}{value .Val ()}
474
+ case []* Var :
475
+ array = make ([]interface {}, len (value ))
476
+ for k , v := range value {
477
+ array [k ] = v .Val ()
478
+ }
460
479
default :
461
480
var (
462
481
rv = reflect .ValueOf (i )
@@ -490,3 +509,9 @@ func toIMap(i interface{}) map[interface{}]interface{} {
490
509
_ = json .Unmarshal (Bytes (i ), & m )
491
510
return m
492
511
}
512
+
513
+ func toSMap (i interface {}) map [string ]string {
514
+ m := make (map [string ]string )
515
+ _ = json .Unmarshal (Bytes (i ), & m )
516
+ return m
517
+ }
0 commit comments