-
-
Notifications
You must be signed in to change notification settings - Fork 1
/
gvar_slice.go
77 lines (63 loc) · 1.75 KB
/
gvar_slice.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
// Copyright GoFrame Author(https://goframe.org). All Rights Reserved.
//
// This Source Code Form is subject to the terms of the MIT License.
// If a copy of the MIT was not distributed with this file,
// You can obtain one at https://github.com/dxasu/gf.
package gvar
import "github.com/dxasu/gf/util/gconv"
// Ints converts and returns <v> as []int.
func (v *Var) Ints() []int {
return gconv.Ints(v.Val())
}
// Int64s converts and returns <v> as []int64.
func (v *Var) Int64s() []int64 {
return gconv.Int64s(v.Val())
}
// Uints converts and returns <v> as []uint.
func (v *Var) Uints() []uint {
return gconv.Uints(v.Val())
}
// Uint64s converts and returns <v> as []uint64.
func (v *Var) Uint64s() []uint64 {
return gconv.Uint64s(v.Val())
}
// Floats is alias of Float64s.
func (v *Var) Floats() []float64 {
return gconv.Floats(v.Val())
}
// Float32s converts and returns <v> as []float32.
func (v *Var) Float32s() []float32 {
return gconv.Float32s(v.Val())
}
// Float64s converts and returns <v> as []float64.
func (v *Var) Float64s() []float64 {
return gconv.Float64s(v.Val())
}
// Strings converts and returns <v> as []string.
func (v *Var) Strings() []string {
return gconv.Strings(v.Val())
}
// Interfaces converts and returns <v> as []interfaces{}.
func (v *Var) Interfaces() []interface{} {
return gconv.Interfaces(v.Val())
}
// Slice is alias of Interfaces.
func (v *Var) Slice() []interface{} {
return v.Interfaces()
}
// Array is alias of Interfaces.
func (v *Var) Array() []interface{} {
return v.Interfaces()
}
// Vars converts and returns <v> as []Var.
func (v *Var) Vars() []*Var {
array := gconv.Interfaces(v.Val())
if len(array) == 0 {
return nil
}
vars := make([]*Var, len(array))
for k, v := range array {
vars[k] = New(v)
}
return vars
}