4 Inter (interface{} and []interface{})
5 --------------------------------------------------
8 // Inter gets the value as a interface{}, returns the optionalDefault
9 // value or a system default object if the value is the wrong type.
10 func (v *Value) Inter(optionalDefault ...interface{}) interface{} {
11 if s, ok := v.data.(interface{}); ok {
14 if len(optionalDefault) == 1 {
15 return optionalDefault[0]
20 // MustInter gets the value as a interface{}.
22 // Panics if the object is not a interface{}.
23 func (v *Value) MustInter() interface{} {
24 return v.data.(interface{})
27 // InterSlice gets the value as a []interface{}, returns the optionalDefault
28 // value or nil if the value is not a []interface{}.
29 func (v *Value) InterSlice(optionalDefault ...[]interface{}) []interface{} {
30 if s, ok := v.data.([]interface{}); ok {
33 if len(optionalDefault) == 1 {
34 return optionalDefault[0]
39 // MustInterSlice gets the value as a []interface{}.
41 // Panics if the object is not a []interface{}.
42 func (v *Value) MustInterSlice() []interface{} {
43 return v.data.([]interface{})
46 // IsInter gets whether the object contained is a interface{} or not.
47 func (v *Value) IsInter() bool {
48 _, ok := v.data.(interface{})
52 // IsInterSlice gets whether the object contained is a []interface{} or not.
53 func (v *Value) IsInterSlice() bool {
54 _, ok := v.data.([]interface{})
58 // EachInter calls the specified callback for each object
59 // in the []interface{}.
61 // Panics if the object is the wrong type.
62 func (v *Value) EachInter(callback func(int, interface{}) bool) *Value {
64 for index, val := range v.MustInterSlice() {
65 carryon := callback(index, val)
75 // WhereInter uses the specified decider function to select items
76 // from the []interface{}. The object contained in the result will contain
77 // only the selected items.
78 func (v *Value) WhereInter(decider func(int, interface{}) bool) *Value {
80 var selected []interface{}
82 v.EachInter(func(index int, val interface{}) bool {
83 shouldSelect := decider(index, val)
84 if shouldSelect == false {
85 selected = append(selected, val)
90 return &Value{data: selected}
94 // GroupInter uses the specified grouper function to group the items
95 // keyed by the return of the grouper. The object contained in the
96 // result will contain a map[string][]interface{}.
97 func (v *Value) GroupInter(grouper func(int, interface{}) string) *Value {
99 groups := make(map[string][]interface{})
101 v.EachInter(func(index int, val interface{}) bool {
102 group := grouper(index, val)
103 if _, ok := groups[group]; !ok {
104 groups[group] = make([]interface{}, 0)
106 groups[group] = append(groups[group], val)
110 return &Value{data: groups}
114 // ReplaceInter uses the specified function to replace each interface{}s
115 // by iterating each item. The data in the returned result will be a
116 // []interface{} containing the replaced items.
117 func (v *Value) ReplaceInter(replacer func(int, interface{}) interface{}) *Value {
119 arr := v.MustInterSlice()
120 replaced := make([]interface{}, len(arr))
122 v.EachInter(func(index int, val interface{}) bool {
123 replaced[index] = replacer(index, val)
127 return &Value{data: replaced}
131 // CollectInter uses the specified collector function to collect a value
132 // for each of the interface{}s in the slice. The data returned will be a
134 func (v *Value) CollectInter(collector func(int, interface{}) interface{}) *Value {
136 arr := v.MustInterSlice()
137 collected := make([]interface{}, len(arr))
139 v.EachInter(func(index int, val interface{}) bool {
140 collected[index] = collector(index, val)
144 return &Value{data: collected}
148 MSI (map[string]interface{} and []map[string]interface{})
149 --------------------------------------------------
152 // MSI gets the value as a map[string]interface{}, returns the optionalDefault
153 // value or a system default object if the value is the wrong type.
154 func (v *Value) MSI(optionalDefault ...map[string]interface{}) map[string]interface{} {
155 if s, ok := v.data.(map[string]interface{}); ok {
158 if len(optionalDefault) == 1 {
159 return optionalDefault[0]
164 // MustMSI gets the value as a map[string]interface{}.
166 // Panics if the object is not a map[string]interface{}.
167 func (v *Value) MustMSI() map[string]interface{} {
168 return v.data.(map[string]interface{})
171 // MSISlice gets the value as a []map[string]interface{}, returns the optionalDefault
172 // value or nil if the value is not a []map[string]interface{}.
173 func (v *Value) MSISlice(optionalDefault ...[]map[string]interface{}) []map[string]interface{} {
174 if s, ok := v.data.([]map[string]interface{}); ok {
177 if len(optionalDefault) == 1 {
178 return optionalDefault[0]
183 // MustMSISlice gets the value as a []map[string]interface{}.
185 // Panics if the object is not a []map[string]interface{}.
186 func (v *Value) MustMSISlice() []map[string]interface{} {
187 return v.data.([]map[string]interface{})
190 // IsMSI gets whether the object contained is a map[string]interface{} or not.
191 func (v *Value) IsMSI() bool {
192 _, ok := v.data.(map[string]interface{})
196 // IsMSISlice gets whether the object contained is a []map[string]interface{} or not.
197 func (v *Value) IsMSISlice() bool {
198 _, ok := v.data.([]map[string]interface{})
202 // EachMSI calls the specified callback for each object
203 // in the []map[string]interface{}.
205 // Panics if the object is the wrong type.
206 func (v *Value) EachMSI(callback func(int, map[string]interface{}) bool) *Value {
208 for index, val := range v.MustMSISlice() {
209 carryon := callback(index, val)
210 if carryon == false {
219 // WhereMSI uses the specified decider function to select items
220 // from the []map[string]interface{}. The object contained in the result will contain
221 // only the selected items.
222 func (v *Value) WhereMSI(decider func(int, map[string]interface{}) bool) *Value {
224 var selected []map[string]interface{}
226 v.EachMSI(func(index int, val map[string]interface{}) bool {
227 shouldSelect := decider(index, val)
228 if shouldSelect == false {
229 selected = append(selected, val)
234 return &Value{data: selected}
238 // GroupMSI uses the specified grouper function to group the items
239 // keyed by the return of the grouper. The object contained in the
240 // result will contain a map[string][]map[string]interface{}.
241 func (v *Value) GroupMSI(grouper func(int, map[string]interface{}) string) *Value {
243 groups := make(map[string][]map[string]interface{})
245 v.EachMSI(func(index int, val map[string]interface{}) bool {
246 group := grouper(index, val)
247 if _, ok := groups[group]; !ok {
248 groups[group] = make([]map[string]interface{}, 0)
250 groups[group] = append(groups[group], val)
254 return &Value{data: groups}
258 // ReplaceMSI uses the specified function to replace each map[string]interface{}s
259 // by iterating each item. The data in the returned result will be a
260 // []map[string]interface{} containing the replaced items.
261 func (v *Value) ReplaceMSI(replacer func(int, map[string]interface{}) map[string]interface{}) *Value {
263 arr := v.MustMSISlice()
264 replaced := make([]map[string]interface{}, len(arr))
266 v.EachMSI(func(index int, val map[string]interface{}) bool {
267 replaced[index] = replacer(index, val)
271 return &Value{data: replaced}
275 // CollectMSI uses the specified collector function to collect a value
276 // for each of the map[string]interface{}s in the slice. The data returned will be a
278 func (v *Value) CollectMSI(collector func(int, map[string]interface{}) interface{}) *Value {
280 arr := v.MustMSISlice()
281 collected := make([]interface{}, len(arr))
283 v.EachMSI(func(index int, val map[string]interface{}) bool {
284 collected[index] = collector(index, val)
288 return &Value{data: collected}
292 ObjxMap ((Map) and [](Map))
293 --------------------------------------------------
296 // ObjxMap gets the value as a (Map), returns the optionalDefault
297 // value or a system default object if the value is the wrong type.
298 func (v *Value) ObjxMap(optionalDefault ...(Map)) Map {
299 if s, ok := v.data.((Map)); ok {
302 if len(optionalDefault) == 1 {
303 return optionalDefault[0]
308 // MustObjxMap gets the value as a (Map).
310 // Panics if the object is not a (Map).
311 func (v *Value) MustObjxMap() Map {
312 return v.data.((Map))
315 // ObjxMapSlice gets the value as a [](Map), returns the optionalDefault
316 // value or nil if the value is not a [](Map).
317 func (v *Value) ObjxMapSlice(optionalDefault ...[](Map)) [](Map) {
318 if s, ok := v.data.([](Map)); ok {
321 if len(optionalDefault) == 1 {
322 return optionalDefault[0]
327 // MustObjxMapSlice gets the value as a [](Map).
329 // Panics if the object is not a [](Map).
330 func (v *Value) MustObjxMapSlice() [](Map) {
331 return v.data.([](Map))
334 // IsObjxMap gets whether the object contained is a (Map) or not.
335 func (v *Value) IsObjxMap() bool {
336 _, ok := v.data.((Map))
340 // IsObjxMapSlice gets whether the object contained is a [](Map) or not.
341 func (v *Value) IsObjxMapSlice() bool {
342 _, ok := v.data.([](Map))
346 // EachObjxMap calls the specified callback for each object
349 // Panics if the object is the wrong type.
350 func (v *Value) EachObjxMap(callback func(int, Map) bool) *Value {
352 for index, val := range v.MustObjxMapSlice() {
353 carryon := callback(index, val)
354 if carryon == false {
363 // WhereObjxMap uses the specified decider function to select items
364 // from the [](Map). The object contained in the result will contain
365 // only the selected items.
366 func (v *Value) WhereObjxMap(decider func(int, Map) bool) *Value {
370 v.EachObjxMap(func(index int, val Map) bool {
371 shouldSelect := decider(index, val)
372 if shouldSelect == false {
373 selected = append(selected, val)
378 return &Value{data: selected}
382 // GroupObjxMap uses the specified grouper function to group the items
383 // keyed by the return of the grouper. The object contained in the
384 // result will contain a map[string][](Map).
385 func (v *Value) GroupObjxMap(grouper func(int, Map) string) *Value {
387 groups := make(map[string][](Map))
389 v.EachObjxMap(func(index int, val Map) bool {
390 group := grouper(index, val)
391 if _, ok := groups[group]; !ok {
392 groups[group] = make([](Map), 0)
394 groups[group] = append(groups[group], val)
398 return &Value{data: groups}
402 // ReplaceObjxMap uses the specified function to replace each (Map)s
403 // by iterating each item. The data in the returned result will be a
404 // [](Map) containing the replaced items.
405 func (v *Value) ReplaceObjxMap(replacer func(int, Map) Map) *Value {
407 arr := v.MustObjxMapSlice()
408 replaced := make([](Map), len(arr))
410 v.EachObjxMap(func(index int, val Map) bool {
411 replaced[index] = replacer(index, val)
415 return &Value{data: replaced}
419 // CollectObjxMap uses the specified collector function to collect a value
420 // for each of the (Map)s in the slice. The data returned will be a
422 func (v *Value) CollectObjxMap(collector func(int, Map) interface{}) *Value {
424 arr := v.MustObjxMapSlice()
425 collected := make([]interface{}, len(arr))
427 v.EachObjxMap(func(index int, val Map) bool {
428 collected[index] = collector(index, val)
432 return &Value{data: collected}
436 Bool (bool and []bool)
437 --------------------------------------------------
440 // Bool gets the value as a bool, returns the optionalDefault
441 // value or a system default object if the value is the wrong type.
442 func (v *Value) Bool(optionalDefault ...bool) bool {
443 if s, ok := v.data.(bool); ok {
446 if len(optionalDefault) == 1 {
447 return optionalDefault[0]
452 // MustBool gets the value as a bool.
454 // Panics if the object is not a bool.
455 func (v *Value) MustBool() bool {
459 // BoolSlice gets the value as a []bool, returns the optionalDefault
460 // value or nil if the value is not a []bool.
461 func (v *Value) BoolSlice(optionalDefault ...[]bool) []bool {
462 if s, ok := v.data.([]bool); ok {
465 if len(optionalDefault) == 1 {
466 return optionalDefault[0]
471 // MustBoolSlice gets the value as a []bool.
473 // Panics if the object is not a []bool.
474 func (v *Value) MustBoolSlice() []bool {
475 return v.data.([]bool)
478 // IsBool gets whether the object contained is a bool or not.
479 func (v *Value) IsBool() bool {
480 _, ok := v.data.(bool)
484 // IsBoolSlice gets whether the object contained is a []bool or not.
485 func (v *Value) IsBoolSlice() bool {
486 _, ok := v.data.([]bool)
490 // EachBool calls the specified callback for each object
493 // Panics if the object is the wrong type.
494 func (v *Value) EachBool(callback func(int, bool) bool) *Value {
496 for index, val := range v.MustBoolSlice() {
497 carryon := callback(index, val)
498 if carryon == false {
507 // WhereBool uses the specified decider function to select items
508 // from the []bool. The object contained in the result will contain
509 // only the selected items.
510 func (v *Value) WhereBool(decider func(int, bool) bool) *Value {
514 v.EachBool(func(index int, val bool) bool {
515 shouldSelect := decider(index, val)
516 if shouldSelect == false {
517 selected = append(selected, val)
522 return &Value{data: selected}
526 // GroupBool uses the specified grouper function to group the items
527 // keyed by the return of the grouper. The object contained in the
528 // result will contain a map[string][]bool.
529 func (v *Value) GroupBool(grouper func(int, bool) string) *Value {
531 groups := make(map[string][]bool)
533 v.EachBool(func(index int, val bool) bool {
534 group := grouper(index, val)
535 if _, ok := groups[group]; !ok {
536 groups[group] = make([]bool, 0)
538 groups[group] = append(groups[group], val)
542 return &Value{data: groups}
546 // ReplaceBool uses the specified function to replace each bools
547 // by iterating each item. The data in the returned result will be a
548 // []bool containing the replaced items.
549 func (v *Value) ReplaceBool(replacer func(int, bool) bool) *Value {
551 arr := v.MustBoolSlice()
552 replaced := make([]bool, len(arr))
554 v.EachBool(func(index int, val bool) bool {
555 replaced[index] = replacer(index, val)
559 return &Value{data: replaced}
563 // CollectBool uses the specified collector function to collect a value
564 // for each of the bools in the slice. The data returned will be a
566 func (v *Value) CollectBool(collector func(int, bool) interface{}) *Value {
568 arr := v.MustBoolSlice()
569 collected := make([]interface{}, len(arr))
571 v.EachBool(func(index int, val bool) bool {
572 collected[index] = collector(index, val)
576 return &Value{data: collected}
580 Str (string and []string)
581 --------------------------------------------------
584 // Str gets the value as a string, returns the optionalDefault
585 // value or a system default object if the value is the wrong type.
586 func (v *Value) Str(optionalDefault ...string) string {
587 if s, ok := v.data.(string); ok {
590 if len(optionalDefault) == 1 {
591 return optionalDefault[0]
596 // MustStr gets the value as a string.
598 // Panics if the object is not a string.
599 func (v *Value) MustStr() string {
600 return v.data.(string)
603 // StrSlice gets the value as a []string, returns the optionalDefault
604 // value or nil if the value is not a []string.
605 func (v *Value) StrSlice(optionalDefault ...[]string) []string {
606 if s, ok := v.data.([]string); ok {
609 if len(optionalDefault) == 1 {
610 return optionalDefault[0]
615 // MustStrSlice gets the value as a []string.
617 // Panics if the object is not a []string.
618 func (v *Value) MustStrSlice() []string {
619 return v.data.([]string)
622 // IsStr gets whether the object contained is a string or not.
623 func (v *Value) IsStr() bool {
624 _, ok := v.data.(string)
628 // IsStrSlice gets whether the object contained is a []string or not.
629 func (v *Value) IsStrSlice() bool {
630 _, ok := v.data.([]string)
634 // EachStr calls the specified callback for each object
637 // Panics if the object is the wrong type.
638 func (v *Value) EachStr(callback func(int, string) bool) *Value {
640 for index, val := range v.MustStrSlice() {
641 carryon := callback(index, val)
642 if carryon == false {
651 // WhereStr uses the specified decider function to select items
652 // from the []string. The object contained in the result will contain
653 // only the selected items.
654 func (v *Value) WhereStr(decider func(int, string) bool) *Value {
656 var selected []string
658 v.EachStr(func(index int, val string) bool {
659 shouldSelect := decider(index, val)
660 if shouldSelect == false {
661 selected = append(selected, val)
666 return &Value{data: selected}
670 // GroupStr uses the specified grouper function to group the items
671 // keyed by the return of the grouper. The object contained in the
672 // result will contain a map[string][]string.
673 func (v *Value) GroupStr(grouper func(int, string) string) *Value {
675 groups := make(map[string][]string)
677 v.EachStr(func(index int, val string) bool {
678 group := grouper(index, val)
679 if _, ok := groups[group]; !ok {
680 groups[group] = make([]string, 0)
682 groups[group] = append(groups[group], val)
686 return &Value{data: groups}
690 // ReplaceStr uses the specified function to replace each strings
691 // by iterating each item. The data in the returned result will be a
692 // []string containing the replaced items.
693 func (v *Value) ReplaceStr(replacer func(int, string) string) *Value {
695 arr := v.MustStrSlice()
696 replaced := make([]string, len(arr))
698 v.EachStr(func(index int, val string) bool {
699 replaced[index] = replacer(index, val)
703 return &Value{data: replaced}
707 // CollectStr uses the specified collector function to collect a value
708 // for each of the strings in the slice. The data returned will be a
710 func (v *Value) CollectStr(collector func(int, string) interface{}) *Value {
712 arr := v.MustStrSlice()
713 collected := make([]interface{}, len(arr))
715 v.EachStr(func(index int, val string) bool {
716 collected[index] = collector(index, val)
720 return &Value{data: collected}
725 --------------------------------------------------
728 // Int gets the value as a int, returns the optionalDefault
729 // value or a system default object if the value is the wrong type.
730 func (v *Value) Int(optionalDefault ...int) int {
731 if s, ok := v.data.(int); ok {
734 if len(optionalDefault) == 1 {
735 return optionalDefault[0]
740 // MustInt gets the value as a int.
742 // Panics if the object is not a int.
743 func (v *Value) MustInt() int {
747 // IntSlice gets the value as a []int, returns the optionalDefault
748 // value or nil if the value is not a []int.
749 func (v *Value) IntSlice(optionalDefault ...[]int) []int {
750 if s, ok := v.data.([]int); ok {
753 if len(optionalDefault) == 1 {
754 return optionalDefault[0]
759 // MustIntSlice gets the value as a []int.
761 // Panics if the object is not a []int.
762 func (v *Value) MustIntSlice() []int {
763 return v.data.([]int)
766 // IsInt gets whether the object contained is a int or not.
767 func (v *Value) IsInt() bool {
768 _, ok := v.data.(int)
772 // IsIntSlice gets whether the object contained is a []int or not.
773 func (v *Value) IsIntSlice() bool {
774 _, ok := v.data.([]int)
778 // EachInt calls the specified callback for each object
781 // Panics if the object is the wrong type.
782 func (v *Value) EachInt(callback func(int, int) bool) *Value {
784 for index, val := range v.MustIntSlice() {
785 carryon := callback(index, val)
786 if carryon == false {
795 // WhereInt uses the specified decider function to select items
796 // from the []int. The object contained in the result will contain
797 // only the selected items.
798 func (v *Value) WhereInt(decider func(int, int) bool) *Value {
802 v.EachInt(func(index int, val int) bool {
803 shouldSelect := decider(index, val)
804 if shouldSelect == false {
805 selected = append(selected, val)
810 return &Value{data: selected}
814 // GroupInt uses the specified grouper function to group the items
815 // keyed by the return of the grouper. The object contained in the
816 // result will contain a map[string][]int.
817 func (v *Value) GroupInt(grouper func(int, int) string) *Value {
819 groups := make(map[string][]int)
821 v.EachInt(func(index int, val int) bool {
822 group := grouper(index, val)
823 if _, ok := groups[group]; !ok {
824 groups[group] = make([]int, 0)
826 groups[group] = append(groups[group], val)
830 return &Value{data: groups}
834 // ReplaceInt uses the specified function to replace each ints
835 // by iterating each item. The data in the returned result will be a
836 // []int containing the replaced items.
837 func (v *Value) ReplaceInt(replacer func(int, int) int) *Value {
839 arr := v.MustIntSlice()
840 replaced := make([]int, len(arr))
842 v.EachInt(func(index int, val int) bool {
843 replaced[index] = replacer(index, val)
847 return &Value{data: replaced}
851 // CollectInt uses the specified collector function to collect a value
852 // for each of the ints in the slice. The data returned will be a
854 func (v *Value) CollectInt(collector func(int, int) interface{}) *Value {
856 arr := v.MustIntSlice()
857 collected := make([]interface{}, len(arr))
859 v.EachInt(func(index int, val int) bool {
860 collected[index] = collector(index, val)
864 return &Value{data: collected}
868 Int8 (int8 and []int8)
869 --------------------------------------------------
872 // Int8 gets the value as a int8, returns the optionalDefault
873 // value or a system default object if the value is the wrong type.
874 func (v *Value) Int8(optionalDefault ...int8) int8 {
875 if s, ok := v.data.(int8); ok {
878 if len(optionalDefault) == 1 {
879 return optionalDefault[0]
884 // MustInt8 gets the value as a int8.
886 // Panics if the object is not a int8.
887 func (v *Value) MustInt8() int8 {
891 // Int8Slice gets the value as a []int8, returns the optionalDefault
892 // value or nil if the value is not a []int8.
893 func (v *Value) Int8Slice(optionalDefault ...[]int8) []int8 {
894 if s, ok := v.data.([]int8); ok {
897 if len(optionalDefault) == 1 {
898 return optionalDefault[0]
903 // MustInt8Slice gets the value as a []int8.
905 // Panics if the object is not a []int8.
906 func (v *Value) MustInt8Slice() []int8 {
907 return v.data.([]int8)
910 // IsInt8 gets whether the object contained is a int8 or not.
911 func (v *Value) IsInt8() bool {
912 _, ok := v.data.(int8)
916 // IsInt8Slice gets whether the object contained is a []int8 or not.
917 func (v *Value) IsInt8Slice() bool {
918 _, ok := v.data.([]int8)
922 // EachInt8 calls the specified callback for each object
925 // Panics if the object is the wrong type.
926 func (v *Value) EachInt8(callback func(int, int8) bool) *Value {
928 for index, val := range v.MustInt8Slice() {
929 carryon := callback(index, val)
930 if carryon == false {
939 // WhereInt8 uses the specified decider function to select items
940 // from the []int8. The object contained in the result will contain
941 // only the selected items.
942 func (v *Value) WhereInt8(decider func(int, int8) bool) *Value {
946 v.EachInt8(func(index int, val int8) bool {
947 shouldSelect := decider(index, val)
948 if shouldSelect == false {
949 selected = append(selected, val)
954 return &Value{data: selected}
958 // GroupInt8 uses the specified grouper function to group the items
959 // keyed by the return of the grouper. The object contained in the
960 // result will contain a map[string][]int8.
961 func (v *Value) GroupInt8(grouper func(int, int8) string) *Value {
963 groups := make(map[string][]int8)
965 v.EachInt8(func(index int, val int8) bool {
966 group := grouper(index, val)
967 if _, ok := groups[group]; !ok {
968 groups[group] = make([]int8, 0)
970 groups[group] = append(groups[group], val)
974 return &Value{data: groups}
978 // ReplaceInt8 uses the specified function to replace each int8s
979 // by iterating each item. The data in the returned result will be a
980 // []int8 containing the replaced items.
981 func (v *Value) ReplaceInt8(replacer func(int, int8) int8) *Value {
983 arr := v.MustInt8Slice()
984 replaced := make([]int8, len(arr))
986 v.EachInt8(func(index int, val int8) bool {
987 replaced[index] = replacer(index, val)
991 return &Value{data: replaced}
995 // CollectInt8 uses the specified collector function to collect a value
996 // for each of the int8s in the slice. The data returned will be a
998 func (v *Value) CollectInt8(collector func(int, int8) interface{}) *Value {
1000 arr := v.MustInt8Slice()
1001 collected := make([]interface{}, len(arr))
1003 v.EachInt8(func(index int, val int8) bool {
1004 collected[index] = collector(index, val)
1008 return &Value{data: collected}
1012 Int16 (int16 and []int16)
1013 --------------------------------------------------
1016 // Int16 gets the value as a int16, returns the optionalDefault
1017 // value or a system default object if the value is the wrong type.
1018 func (v *Value) Int16(optionalDefault ...int16) int16 {
1019 if s, ok := v.data.(int16); ok {
1022 if len(optionalDefault) == 1 {
1023 return optionalDefault[0]
1028 // MustInt16 gets the value as a int16.
1030 // Panics if the object is not a int16.
1031 func (v *Value) MustInt16() int16 {
1032 return v.data.(int16)
1035 // Int16Slice gets the value as a []int16, returns the optionalDefault
1036 // value or nil if the value is not a []int16.
1037 func (v *Value) Int16Slice(optionalDefault ...[]int16) []int16 {
1038 if s, ok := v.data.([]int16); ok {
1041 if len(optionalDefault) == 1 {
1042 return optionalDefault[0]
1047 // MustInt16Slice gets the value as a []int16.
1049 // Panics if the object is not a []int16.
1050 func (v *Value) MustInt16Slice() []int16 {
1051 return v.data.([]int16)
1054 // IsInt16 gets whether the object contained is a int16 or not.
1055 func (v *Value) IsInt16() bool {
1056 _, ok := v.data.(int16)
1060 // IsInt16Slice gets whether the object contained is a []int16 or not.
1061 func (v *Value) IsInt16Slice() bool {
1062 _, ok := v.data.([]int16)
1066 // EachInt16 calls the specified callback for each object
1069 // Panics if the object is the wrong type.
1070 func (v *Value) EachInt16(callback func(int, int16) bool) *Value {
1072 for index, val := range v.MustInt16Slice() {
1073 carryon := callback(index, val)
1074 if carryon == false {
1083 // WhereInt16 uses the specified decider function to select items
1084 // from the []int16. The object contained in the result will contain
1085 // only the selected items.
1086 func (v *Value) WhereInt16(decider func(int, int16) bool) *Value {
1088 var selected []int16
1090 v.EachInt16(func(index int, val int16) bool {
1091 shouldSelect := decider(index, val)
1092 if shouldSelect == false {
1093 selected = append(selected, val)
1098 return &Value{data: selected}
1102 // GroupInt16 uses the specified grouper function to group the items
1103 // keyed by the return of the grouper. The object contained in the
1104 // result will contain a map[string][]int16.
1105 func (v *Value) GroupInt16(grouper func(int, int16) string) *Value {
1107 groups := make(map[string][]int16)
1109 v.EachInt16(func(index int, val int16) bool {
1110 group := grouper(index, val)
1111 if _, ok := groups[group]; !ok {
1112 groups[group] = make([]int16, 0)
1114 groups[group] = append(groups[group], val)
1118 return &Value{data: groups}
1122 // ReplaceInt16 uses the specified function to replace each int16s
1123 // by iterating each item. The data in the returned result will be a
1124 // []int16 containing the replaced items.
1125 func (v *Value) ReplaceInt16(replacer func(int, int16) int16) *Value {
1127 arr := v.MustInt16Slice()
1128 replaced := make([]int16, len(arr))
1130 v.EachInt16(func(index int, val int16) bool {
1131 replaced[index] = replacer(index, val)
1135 return &Value{data: replaced}
1139 // CollectInt16 uses the specified collector function to collect a value
1140 // for each of the int16s in the slice. The data returned will be a
1142 func (v *Value) CollectInt16(collector func(int, int16) interface{}) *Value {
1144 arr := v.MustInt16Slice()
1145 collected := make([]interface{}, len(arr))
1147 v.EachInt16(func(index int, val int16) bool {
1148 collected[index] = collector(index, val)
1152 return &Value{data: collected}
1156 Int32 (int32 and []int32)
1157 --------------------------------------------------
1160 // Int32 gets the value as a int32, returns the optionalDefault
1161 // value or a system default object if the value is the wrong type.
1162 func (v *Value) Int32(optionalDefault ...int32) int32 {
1163 if s, ok := v.data.(int32); ok {
1166 if len(optionalDefault) == 1 {
1167 return optionalDefault[0]
1172 // MustInt32 gets the value as a int32.
1174 // Panics if the object is not a int32.
1175 func (v *Value) MustInt32() int32 {
1176 return v.data.(int32)
1179 // Int32Slice gets the value as a []int32, returns the optionalDefault
1180 // value or nil if the value is not a []int32.
1181 func (v *Value) Int32Slice(optionalDefault ...[]int32) []int32 {
1182 if s, ok := v.data.([]int32); ok {
1185 if len(optionalDefault) == 1 {
1186 return optionalDefault[0]
1191 // MustInt32Slice gets the value as a []int32.
1193 // Panics if the object is not a []int32.
1194 func (v *Value) MustInt32Slice() []int32 {
1195 return v.data.([]int32)
1198 // IsInt32 gets whether the object contained is a int32 or not.
1199 func (v *Value) IsInt32() bool {
1200 _, ok := v.data.(int32)
1204 // IsInt32Slice gets whether the object contained is a []int32 or not.
1205 func (v *Value) IsInt32Slice() bool {
1206 _, ok := v.data.([]int32)
1210 // EachInt32 calls the specified callback for each object
1213 // Panics if the object is the wrong type.
1214 func (v *Value) EachInt32(callback func(int, int32) bool) *Value {
1216 for index, val := range v.MustInt32Slice() {
1217 carryon := callback(index, val)
1218 if carryon == false {
1227 // WhereInt32 uses the specified decider function to select items
1228 // from the []int32. The object contained in the result will contain
1229 // only the selected items.
1230 func (v *Value) WhereInt32(decider func(int, int32) bool) *Value {
1232 var selected []int32
1234 v.EachInt32(func(index int, val int32) bool {
1235 shouldSelect := decider(index, val)
1236 if shouldSelect == false {
1237 selected = append(selected, val)
1242 return &Value{data: selected}
1246 // GroupInt32 uses the specified grouper function to group the items
1247 // keyed by the return of the grouper. The object contained in the
1248 // result will contain a map[string][]int32.
1249 func (v *Value) GroupInt32(grouper func(int, int32) string) *Value {
1251 groups := make(map[string][]int32)
1253 v.EachInt32(func(index int, val int32) bool {
1254 group := grouper(index, val)
1255 if _, ok := groups[group]; !ok {
1256 groups[group] = make([]int32, 0)
1258 groups[group] = append(groups[group], val)
1262 return &Value{data: groups}
1266 // ReplaceInt32 uses the specified function to replace each int32s
1267 // by iterating each item. The data in the returned result will be a
1268 // []int32 containing the replaced items.
1269 func (v *Value) ReplaceInt32(replacer func(int, int32) int32) *Value {
1271 arr := v.MustInt32Slice()
1272 replaced := make([]int32, len(arr))
1274 v.EachInt32(func(index int, val int32) bool {
1275 replaced[index] = replacer(index, val)
1279 return &Value{data: replaced}
1283 // CollectInt32 uses the specified collector function to collect a value
1284 // for each of the int32s in the slice. The data returned will be a
1286 func (v *Value) CollectInt32(collector func(int, int32) interface{}) *Value {
1288 arr := v.MustInt32Slice()
1289 collected := make([]interface{}, len(arr))
1291 v.EachInt32(func(index int, val int32) bool {
1292 collected[index] = collector(index, val)
1296 return &Value{data: collected}
1300 Int64 (int64 and []int64)
1301 --------------------------------------------------
1304 // Int64 gets the value as a int64, returns the optionalDefault
1305 // value or a system default object if the value is the wrong type.
1306 func (v *Value) Int64(optionalDefault ...int64) int64 {
1307 if s, ok := v.data.(int64); ok {
1310 if len(optionalDefault) == 1 {
1311 return optionalDefault[0]
1316 // MustInt64 gets the value as a int64.
1318 // Panics if the object is not a int64.
1319 func (v *Value) MustInt64() int64 {
1320 return v.data.(int64)
1323 // Int64Slice gets the value as a []int64, returns the optionalDefault
1324 // value or nil if the value is not a []int64.
1325 func (v *Value) Int64Slice(optionalDefault ...[]int64) []int64 {
1326 if s, ok := v.data.([]int64); ok {
1329 if len(optionalDefault) == 1 {
1330 return optionalDefault[0]
1335 // MustInt64Slice gets the value as a []int64.
1337 // Panics if the object is not a []int64.
1338 func (v *Value) MustInt64Slice() []int64 {
1339 return v.data.([]int64)
1342 // IsInt64 gets whether the object contained is a int64 or not.
1343 func (v *Value) IsInt64() bool {
1344 _, ok := v.data.(int64)
1348 // IsInt64Slice gets whether the object contained is a []int64 or not.
1349 func (v *Value) IsInt64Slice() bool {
1350 _, ok := v.data.([]int64)
1354 // EachInt64 calls the specified callback for each object
1357 // Panics if the object is the wrong type.
1358 func (v *Value) EachInt64(callback func(int, int64) bool) *Value {
1360 for index, val := range v.MustInt64Slice() {
1361 carryon := callback(index, val)
1362 if carryon == false {
1371 // WhereInt64 uses the specified decider function to select items
1372 // from the []int64. The object contained in the result will contain
1373 // only the selected items.
1374 func (v *Value) WhereInt64(decider func(int, int64) bool) *Value {
1376 var selected []int64
1378 v.EachInt64(func(index int, val int64) bool {
1379 shouldSelect := decider(index, val)
1380 if shouldSelect == false {
1381 selected = append(selected, val)
1386 return &Value{data: selected}
1390 // GroupInt64 uses the specified grouper function to group the items
1391 // keyed by the return of the grouper. The object contained in the
1392 // result will contain a map[string][]int64.
1393 func (v *Value) GroupInt64(grouper func(int, int64) string) *Value {
1395 groups := make(map[string][]int64)
1397 v.EachInt64(func(index int, val int64) bool {
1398 group := grouper(index, val)
1399 if _, ok := groups[group]; !ok {
1400 groups[group] = make([]int64, 0)
1402 groups[group] = append(groups[group], val)
1406 return &Value{data: groups}
1410 // ReplaceInt64 uses the specified function to replace each int64s
1411 // by iterating each item. The data in the returned result will be a
1412 // []int64 containing the replaced items.
1413 func (v *Value) ReplaceInt64(replacer func(int, int64) int64) *Value {
1415 arr := v.MustInt64Slice()
1416 replaced := make([]int64, len(arr))
1418 v.EachInt64(func(index int, val int64) bool {
1419 replaced[index] = replacer(index, val)
1423 return &Value{data: replaced}
1427 // CollectInt64 uses the specified collector function to collect a value
1428 // for each of the int64s in the slice. The data returned will be a
1430 func (v *Value) CollectInt64(collector func(int, int64) interface{}) *Value {
1432 arr := v.MustInt64Slice()
1433 collected := make([]interface{}, len(arr))
1435 v.EachInt64(func(index int, val int64) bool {
1436 collected[index] = collector(index, val)
1440 return &Value{data: collected}
1444 Uint (uint and []uint)
1445 --------------------------------------------------
1448 // Uint gets the value as a uint, returns the optionalDefault
1449 // value or a system default object if the value is the wrong type.
1450 func (v *Value) Uint(optionalDefault ...uint) uint {
1451 if s, ok := v.data.(uint); ok {
1454 if len(optionalDefault) == 1 {
1455 return optionalDefault[0]
1460 // MustUint gets the value as a uint.
1462 // Panics if the object is not a uint.
1463 func (v *Value) MustUint() uint {
1464 return v.data.(uint)
1467 // UintSlice gets the value as a []uint, returns the optionalDefault
1468 // value or nil if the value is not a []uint.
1469 func (v *Value) UintSlice(optionalDefault ...[]uint) []uint {
1470 if s, ok := v.data.([]uint); ok {
1473 if len(optionalDefault) == 1 {
1474 return optionalDefault[0]
1479 // MustUintSlice gets the value as a []uint.
1481 // Panics if the object is not a []uint.
1482 func (v *Value) MustUintSlice() []uint {
1483 return v.data.([]uint)
1486 // IsUint gets whether the object contained is a uint or not.
1487 func (v *Value) IsUint() bool {
1488 _, ok := v.data.(uint)
1492 // IsUintSlice gets whether the object contained is a []uint or not.
1493 func (v *Value) IsUintSlice() bool {
1494 _, ok := v.data.([]uint)
1498 // EachUint calls the specified callback for each object
1501 // Panics if the object is the wrong type.
1502 func (v *Value) EachUint(callback func(int, uint) bool) *Value {
1504 for index, val := range v.MustUintSlice() {
1505 carryon := callback(index, val)
1506 if carryon == false {
1515 // WhereUint uses the specified decider function to select items
1516 // from the []uint. The object contained in the result will contain
1517 // only the selected items.
1518 func (v *Value) WhereUint(decider func(int, uint) bool) *Value {
1522 v.EachUint(func(index int, val uint) bool {
1523 shouldSelect := decider(index, val)
1524 if shouldSelect == false {
1525 selected = append(selected, val)
1530 return &Value{data: selected}
1534 // GroupUint uses the specified grouper function to group the items
1535 // keyed by the return of the grouper. The object contained in the
1536 // result will contain a map[string][]uint.
1537 func (v *Value) GroupUint(grouper func(int, uint) string) *Value {
1539 groups := make(map[string][]uint)
1541 v.EachUint(func(index int, val uint) bool {
1542 group := grouper(index, val)
1543 if _, ok := groups[group]; !ok {
1544 groups[group] = make([]uint, 0)
1546 groups[group] = append(groups[group], val)
1550 return &Value{data: groups}
1554 // ReplaceUint uses the specified function to replace each uints
1555 // by iterating each item. The data in the returned result will be a
1556 // []uint containing the replaced items.
1557 func (v *Value) ReplaceUint(replacer func(int, uint) uint) *Value {
1559 arr := v.MustUintSlice()
1560 replaced := make([]uint, len(arr))
1562 v.EachUint(func(index int, val uint) bool {
1563 replaced[index] = replacer(index, val)
1567 return &Value{data: replaced}
1571 // CollectUint uses the specified collector function to collect a value
1572 // for each of the uints in the slice. The data returned will be a
1574 func (v *Value) CollectUint(collector func(int, uint) interface{}) *Value {
1576 arr := v.MustUintSlice()
1577 collected := make([]interface{}, len(arr))
1579 v.EachUint(func(index int, val uint) bool {
1580 collected[index] = collector(index, val)
1584 return &Value{data: collected}
1588 Uint8 (uint8 and []uint8)
1589 --------------------------------------------------
1592 // Uint8 gets the value as a uint8, returns the optionalDefault
1593 // value or a system default object if the value is the wrong type.
1594 func (v *Value) Uint8(optionalDefault ...uint8) uint8 {
1595 if s, ok := v.data.(uint8); ok {
1598 if len(optionalDefault) == 1 {
1599 return optionalDefault[0]
1604 // MustUint8 gets the value as a uint8.
1606 // Panics if the object is not a uint8.
1607 func (v *Value) MustUint8() uint8 {
1608 return v.data.(uint8)
1611 // Uint8Slice gets the value as a []uint8, returns the optionalDefault
1612 // value or nil if the value is not a []uint8.
1613 func (v *Value) Uint8Slice(optionalDefault ...[]uint8) []uint8 {
1614 if s, ok := v.data.([]uint8); ok {
1617 if len(optionalDefault) == 1 {
1618 return optionalDefault[0]
1623 // MustUint8Slice gets the value as a []uint8.
1625 // Panics if the object is not a []uint8.
1626 func (v *Value) MustUint8Slice() []uint8 {
1627 return v.data.([]uint8)
1630 // IsUint8 gets whether the object contained is a uint8 or not.
1631 func (v *Value) IsUint8() bool {
1632 _, ok := v.data.(uint8)
1636 // IsUint8Slice gets whether the object contained is a []uint8 or not.
1637 func (v *Value) IsUint8Slice() bool {
1638 _, ok := v.data.([]uint8)
1642 // EachUint8 calls the specified callback for each object
1645 // Panics if the object is the wrong type.
1646 func (v *Value) EachUint8(callback func(int, uint8) bool) *Value {
1648 for index, val := range v.MustUint8Slice() {
1649 carryon := callback(index, val)
1650 if carryon == false {
1659 // WhereUint8 uses the specified decider function to select items
1660 // from the []uint8. The object contained in the result will contain
1661 // only the selected items.
1662 func (v *Value) WhereUint8(decider func(int, uint8) bool) *Value {
1664 var selected []uint8
1666 v.EachUint8(func(index int, val uint8) bool {
1667 shouldSelect := decider(index, val)
1668 if shouldSelect == false {
1669 selected = append(selected, val)
1674 return &Value{data: selected}
1678 // GroupUint8 uses the specified grouper function to group the items
1679 // keyed by the return of the grouper. The object contained in the
1680 // result will contain a map[string][]uint8.
1681 func (v *Value) GroupUint8(grouper func(int, uint8) string) *Value {
1683 groups := make(map[string][]uint8)
1685 v.EachUint8(func(index int, val uint8) bool {
1686 group := grouper(index, val)
1687 if _, ok := groups[group]; !ok {
1688 groups[group] = make([]uint8, 0)
1690 groups[group] = append(groups[group], val)
1694 return &Value{data: groups}
1698 // ReplaceUint8 uses the specified function to replace each uint8s
1699 // by iterating each item. The data in the returned result will be a
1700 // []uint8 containing the replaced items.
1701 func (v *Value) ReplaceUint8(replacer func(int, uint8) uint8) *Value {
1703 arr := v.MustUint8Slice()
1704 replaced := make([]uint8, len(arr))
1706 v.EachUint8(func(index int, val uint8) bool {
1707 replaced[index] = replacer(index, val)
1711 return &Value{data: replaced}
1715 // CollectUint8 uses the specified collector function to collect a value
1716 // for each of the uint8s in the slice. The data returned will be a
1718 func (v *Value) CollectUint8(collector func(int, uint8) interface{}) *Value {
1720 arr := v.MustUint8Slice()
1721 collected := make([]interface{}, len(arr))
1723 v.EachUint8(func(index int, val uint8) bool {
1724 collected[index] = collector(index, val)
1728 return &Value{data: collected}
1732 Uint16 (uint16 and []uint16)
1733 --------------------------------------------------
1736 // Uint16 gets the value as a uint16, returns the optionalDefault
1737 // value or a system default object if the value is the wrong type.
1738 func (v *Value) Uint16(optionalDefault ...uint16) uint16 {
1739 if s, ok := v.data.(uint16); ok {
1742 if len(optionalDefault) == 1 {
1743 return optionalDefault[0]
1748 // MustUint16 gets the value as a uint16.
1750 // Panics if the object is not a uint16.
1751 func (v *Value) MustUint16() uint16 {
1752 return v.data.(uint16)
1755 // Uint16Slice gets the value as a []uint16, returns the optionalDefault
1756 // value or nil if the value is not a []uint16.
1757 func (v *Value) Uint16Slice(optionalDefault ...[]uint16) []uint16 {
1758 if s, ok := v.data.([]uint16); ok {
1761 if len(optionalDefault) == 1 {
1762 return optionalDefault[0]
1767 // MustUint16Slice gets the value as a []uint16.
1769 // Panics if the object is not a []uint16.
1770 func (v *Value) MustUint16Slice() []uint16 {
1771 return v.data.([]uint16)
1774 // IsUint16 gets whether the object contained is a uint16 or not.
1775 func (v *Value) IsUint16() bool {
1776 _, ok := v.data.(uint16)
1780 // IsUint16Slice gets whether the object contained is a []uint16 or not.
1781 func (v *Value) IsUint16Slice() bool {
1782 _, ok := v.data.([]uint16)
1786 // EachUint16 calls the specified callback for each object
1789 // Panics if the object is the wrong type.
1790 func (v *Value) EachUint16(callback func(int, uint16) bool) *Value {
1792 for index, val := range v.MustUint16Slice() {
1793 carryon := callback(index, val)
1794 if carryon == false {
1803 // WhereUint16 uses the specified decider function to select items
1804 // from the []uint16. The object contained in the result will contain
1805 // only the selected items.
1806 func (v *Value) WhereUint16(decider func(int, uint16) bool) *Value {
1808 var selected []uint16
1810 v.EachUint16(func(index int, val uint16) bool {
1811 shouldSelect := decider(index, val)
1812 if shouldSelect == false {
1813 selected = append(selected, val)
1818 return &Value{data: selected}
1822 // GroupUint16 uses the specified grouper function to group the items
1823 // keyed by the return of the grouper. The object contained in the
1824 // result will contain a map[string][]uint16.
1825 func (v *Value) GroupUint16(grouper func(int, uint16) string) *Value {
1827 groups := make(map[string][]uint16)
1829 v.EachUint16(func(index int, val uint16) bool {
1830 group := grouper(index, val)
1831 if _, ok := groups[group]; !ok {
1832 groups[group] = make([]uint16, 0)
1834 groups[group] = append(groups[group], val)
1838 return &Value{data: groups}
1842 // ReplaceUint16 uses the specified function to replace each uint16s
1843 // by iterating each item. The data in the returned result will be a
1844 // []uint16 containing the replaced items.
1845 func (v *Value) ReplaceUint16(replacer func(int, uint16) uint16) *Value {
1847 arr := v.MustUint16Slice()
1848 replaced := make([]uint16, len(arr))
1850 v.EachUint16(func(index int, val uint16) bool {
1851 replaced[index] = replacer(index, val)
1855 return &Value{data: replaced}
1859 // CollectUint16 uses the specified collector function to collect a value
1860 // for each of the uint16s in the slice. The data returned will be a
1862 func (v *Value) CollectUint16(collector func(int, uint16) interface{}) *Value {
1864 arr := v.MustUint16Slice()
1865 collected := make([]interface{}, len(arr))
1867 v.EachUint16(func(index int, val uint16) bool {
1868 collected[index] = collector(index, val)
1872 return &Value{data: collected}
1876 Uint32 (uint32 and []uint32)
1877 --------------------------------------------------
1880 // Uint32 gets the value as a uint32, returns the optionalDefault
1881 // value or a system default object if the value is the wrong type.
1882 func (v *Value) Uint32(optionalDefault ...uint32) uint32 {
1883 if s, ok := v.data.(uint32); ok {
1886 if len(optionalDefault) == 1 {
1887 return optionalDefault[0]
1892 // MustUint32 gets the value as a uint32.
1894 // Panics if the object is not a uint32.
1895 func (v *Value) MustUint32() uint32 {
1896 return v.data.(uint32)
1899 // Uint32Slice gets the value as a []uint32, returns the optionalDefault
1900 // value or nil if the value is not a []uint32.
1901 func (v *Value) Uint32Slice(optionalDefault ...[]uint32) []uint32 {
1902 if s, ok := v.data.([]uint32); ok {
1905 if len(optionalDefault) == 1 {
1906 return optionalDefault[0]
1911 // MustUint32Slice gets the value as a []uint32.
1913 // Panics if the object is not a []uint32.
1914 func (v *Value) MustUint32Slice() []uint32 {
1915 return v.data.([]uint32)
1918 // IsUint32 gets whether the object contained is a uint32 or not.
1919 func (v *Value) IsUint32() bool {
1920 _, ok := v.data.(uint32)
1924 // IsUint32Slice gets whether the object contained is a []uint32 or not.
1925 func (v *Value) IsUint32Slice() bool {
1926 _, ok := v.data.([]uint32)
1930 // EachUint32 calls the specified callback for each object
1933 // Panics if the object is the wrong type.
1934 func (v *Value) EachUint32(callback func(int, uint32) bool) *Value {
1936 for index, val := range v.MustUint32Slice() {
1937 carryon := callback(index, val)
1938 if carryon == false {
1947 // WhereUint32 uses the specified decider function to select items
1948 // from the []uint32. The object contained in the result will contain
1949 // only the selected items.
1950 func (v *Value) WhereUint32(decider func(int, uint32) bool) *Value {
1952 var selected []uint32
1954 v.EachUint32(func(index int, val uint32) bool {
1955 shouldSelect := decider(index, val)
1956 if shouldSelect == false {
1957 selected = append(selected, val)
1962 return &Value{data: selected}
1966 // GroupUint32 uses the specified grouper function to group the items
1967 // keyed by the return of the grouper. The object contained in the
1968 // result will contain a map[string][]uint32.
1969 func (v *Value) GroupUint32(grouper func(int, uint32) string) *Value {
1971 groups := make(map[string][]uint32)
1973 v.EachUint32(func(index int, val uint32) bool {
1974 group := grouper(index, val)
1975 if _, ok := groups[group]; !ok {
1976 groups[group] = make([]uint32, 0)
1978 groups[group] = append(groups[group], val)
1982 return &Value{data: groups}
1986 // ReplaceUint32 uses the specified function to replace each uint32s
1987 // by iterating each item. The data in the returned result will be a
1988 // []uint32 containing the replaced items.
1989 func (v *Value) ReplaceUint32(replacer func(int, uint32) uint32) *Value {
1991 arr := v.MustUint32Slice()
1992 replaced := make([]uint32, len(arr))
1994 v.EachUint32(func(index int, val uint32) bool {
1995 replaced[index] = replacer(index, val)
1999 return &Value{data: replaced}
2003 // CollectUint32 uses the specified collector function to collect a value
2004 // for each of the uint32s in the slice. The data returned will be a
2006 func (v *Value) CollectUint32(collector func(int, uint32) interface{}) *Value {
2008 arr := v.MustUint32Slice()
2009 collected := make([]interface{}, len(arr))
2011 v.EachUint32(func(index int, val uint32) bool {
2012 collected[index] = collector(index, val)
2016 return &Value{data: collected}
2020 Uint64 (uint64 and []uint64)
2021 --------------------------------------------------
2024 // Uint64 gets the value as a uint64, returns the optionalDefault
2025 // value or a system default object if the value is the wrong type.
2026 func (v *Value) Uint64(optionalDefault ...uint64) uint64 {
2027 if s, ok := v.data.(uint64); ok {
2030 if len(optionalDefault) == 1 {
2031 return optionalDefault[0]
2036 // MustUint64 gets the value as a uint64.
2038 // Panics if the object is not a uint64.
2039 func (v *Value) MustUint64() uint64 {
2040 return v.data.(uint64)
2043 // Uint64Slice gets the value as a []uint64, returns the optionalDefault
2044 // value or nil if the value is not a []uint64.
2045 func (v *Value) Uint64Slice(optionalDefault ...[]uint64) []uint64 {
2046 if s, ok := v.data.([]uint64); ok {
2049 if len(optionalDefault) == 1 {
2050 return optionalDefault[0]
2055 // MustUint64Slice gets the value as a []uint64.
2057 // Panics if the object is not a []uint64.
2058 func (v *Value) MustUint64Slice() []uint64 {
2059 return v.data.([]uint64)
2062 // IsUint64 gets whether the object contained is a uint64 or not.
2063 func (v *Value) IsUint64() bool {
2064 _, ok := v.data.(uint64)
2068 // IsUint64Slice gets whether the object contained is a []uint64 or not.
2069 func (v *Value) IsUint64Slice() bool {
2070 _, ok := v.data.([]uint64)
2074 // EachUint64 calls the specified callback for each object
2077 // Panics if the object is the wrong type.
2078 func (v *Value) EachUint64(callback func(int, uint64) bool) *Value {
2080 for index, val := range v.MustUint64Slice() {
2081 carryon := callback(index, val)
2082 if carryon == false {
2091 // WhereUint64 uses the specified decider function to select items
2092 // from the []uint64. The object contained in the result will contain
2093 // only the selected items.
2094 func (v *Value) WhereUint64(decider func(int, uint64) bool) *Value {
2096 var selected []uint64
2098 v.EachUint64(func(index int, val uint64) bool {
2099 shouldSelect := decider(index, val)
2100 if shouldSelect == false {
2101 selected = append(selected, val)
2106 return &Value{data: selected}
2110 // GroupUint64 uses the specified grouper function to group the items
2111 // keyed by the return of the grouper. The object contained in the
2112 // result will contain a map[string][]uint64.
2113 func (v *Value) GroupUint64(grouper func(int, uint64) string) *Value {
2115 groups := make(map[string][]uint64)
2117 v.EachUint64(func(index int, val uint64) bool {
2118 group := grouper(index, val)
2119 if _, ok := groups[group]; !ok {
2120 groups[group] = make([]uint64, 0)
2122 groups[group] = append(groups[group], val)
2126 return &Value{data: groups}
2130 // ReplaceUint64 uses the specified function to replace each uint64s
2131 // by iterating each item. The data in the returned result will be a
2132 // []uint64 containing the replaced items.
2133 func (v *Value) ReplaceUint64(replacer func(int, uint64) uint64) *Value {
2135 arr := v.MustUint64Slice()
2136 replaced := make([]uint64, len(arr))
2138 v.EachUint64(func(index int, val uint64) bool {
2139 replaced[index] = replacer(index, val)
2143 return &Value{data: replaced}
2147 // CollectUint64 uses the specified collector function to collect a value
2148 // for each of the uint64s in the slice. The data returned will be a
2150 func (v *Value) CollectUint64(collector func(int, uint64) interface{}) *Value {
2152 arr := v.MustUint64Slice()
2153 collected := make([]interface{}, len(arr))
2155 v.EachUint64(func(index int, val uint64) bool {
2156 collected[index] = collector(index, val)
2160 return &Value{data: collected}
2164 Uintptr (uintptr and []uintptr)
2165 --------------------------------------------------
2168 // Uintptr gets the value as a uintptr, returns the optionalDefault
2169 // value or a system default object if the value is the wrong type.
2170 func (v *Value) Uintptr(optionalDefault ...uintptr) uintptr {
2171 if s, ok := v.data.(uintptr); ok {
2174 if len(optionalDefault) == 1 {
2175 return optionalDefault[0]
2180 // MustUintptr gets the value as a uintptr.
2182 // Panics if the object is not a uintptr.
2183 func (v *Value) MustUintptr() uintptr {
2184 return v.data.(uintptr)
2187 // UintptrSlice gets the value as a []uintptr, returns the optionalDefault
2188 // value or nil if the value is not a []uintptr.
2189 func (v *Value) UintptrSlice(optionalDefault ...[]uintptr) []uintptr {
2190 if s, ok := v.data.([]uintptr); ok {
2193 if len(optionalDefault) == 1 {
2194 return optionalDefault[0]
2199 // MustUintptrSlice gets the value as a []uintptr.
2201 // Panics if the object is not a []uintptr.
2202 func (v *Value) MustUintptrSlice() []uintptr {
2203 return v.data.([]uintptr)
2206 // IsUintptr gets whether the object contained is a uintptr or not.
2207 func (v *Value) IsUintptr() bool {
2208 _, ok := v.data.(uintptr)
2212 // IsUintptrSlice gets whether the object contained is a []uintptr or not.
2213 func (v *Value) IsUintptrSlice() bool {
2214 _, ok := v.data.([]uintptr)
2218 // EachUintptr calls the specified callback for each object
2219 // in the []uintptr.
2221 // Panics if the object is the wrong type.
2222 func (v *Value) EachUintptr(callback func(int, uintptr) bool) *Value {
2224 for index, val := range v.MustUintptrSlice() {
2225 carryon := callback(index, val)
2226 if carryon == false {
2235 // WhereUintptr uses the specified decider function to select items
2236 // from the []uintptr. The object contained in the result will contain
2237 // only the selected items.
2238 func (v *Value) WhereUintptr(decider func(int, uintptr) bool) *Value {
2240 var selected []uintptr
2242 v.EachUintptr(func(index int, val uintptr) bool {
2243 shouldSelect := decider(index, val)
2244 if shouldSelect == false {
2245 selected = append(selected, val)
2250 return &Value{data: selected}
2254 // GroupUintptr uses the specified grouper function to group the items
2255 // keyed by the return of the grouper. The object contained in the
2256 // result will contain a map[string][]uintptr.
2257 func (v *Value) GroupUintptr(grouper func(int, uintptr) string) *Value {
2259 groups := make(map[string][]uintptr)
2261 v.EachUintptr(func(index int, val uintptr) bool {
2262 group := grouper(index, val)
2263 if _, ok := groups[group]; !ok {
2264 groups[group] = make([]uintptr, 0)
2266 groups[group] = append(groups[group], val)
2270 return &Value{data: groups}
2274 // ReplaceUintptr uses the specified function to replace each uintptrs
2275 // by iterating each item. The data in the returned result will be a
2276 // []uintptr containing the replaced items.
2277 func (v *Value) ReplaceUintptr(replacer func(int, uintptr) uintptr) *Value {
2279 arr := v.MustUintptrSlice()
2280 replaced := make([]uintptr, len(arr))
2282 v.EachUintptr(func(index int, val uintptr) bool {
2283 replaced[index] = replacer(index, val)
2287 return &Value{data: replaced}
2291 // CollectUintptr uses the specified collector function to collect a value
2292 // for each of the uintptrs in the slice. The data returned will be a
2294 func (v *Value) CollectUintptr(collector func(int, uintptr) interface{}) *Value {
2296 arr := v.MustUintptrSlice()
2297 collected := make([]interface{}, len(arr))
2299 v.EachUintptr(func(index int, val uintptr) bool {
2300 collected[index] = collector(index, val)
2304 return &Value{data: collected}
2308 Float32 (float32 and []float32)
2309 --------------------------------------------------
2312 // Float32 gets the value as a float32, returns the optionalDefault
2313 // value or a system default object if the value is the wrong type.
2314 func (v *Value) Float32(optionalDefault ...float32) float32 {
2315 if s, ok := v.data.(float32); ok {
2318 if len(optionalDefault) == 1 {
2319 return optionalDefault[0]
2324 // MustFloat32 gets the value as a float32.
2326 // Panics if the object is not a float32.
2327 func (v *Value) MustFloat32() float32 {
2328 return v.data.(float32)
2331 // Float32Slice gets the value as a []float32, returns the optionalDefault
2332 // value or nil if the value is not a []float32.
2333 func (v *Value) Float32Slice(optionalDefault ...[]float32) []float32 {
2334 if s, ok := v.data.([]float32); ok {
2337 if len(optionalDefault) == 1 {
2338 return optionalDefault[0]
2343 // MustFloat32Slice gets the value as a []float32.
2345 // Panics if the object is not a []float32.
2346 func (v *Value) MustFloat32Slice() []float32 {
2347 return v.data.([]float32)
2350 // IsFloat32 gets whether the object contained is a float32 or not.
2351 func (v *Value) IsFloat32() bool {
2352 _, ok := v.data.(float32)
2356 // IsFloat32Slice gets whether the object contained is a []float32 or not.
2357 func (v *Value) IsFloat32Slice() bool {
2358 _, ok := v.data.([]float32)
2362 // EachFloat32 calls the specified callback for each object
2363 // in the []float32.
2365 // Panics if the object is the wrong type.
2366 func (v *Value) EachFloat32(callback func(int, float32) bool) *Value {
2368 for index, val := range v.MustFloat32Slice() {
2369 carryon := callback(index, val)
2370 if carryon == false {
2379 // WhereFloat32 uses the specified decider function to select items
2380 // from the []float32. The object contained in the result will contain
2381 // only the selected items.
2382 func (v *Value) WhereFloat32(decider func(int, float32) bool) *Value {
2384 var selected []float32
2386 v.EachFloat32(func(index int, val float32) bool {
2387 shouldSelect := decider(index, val)
2388 if shouldSelect == false {
2389 selected = append(selected, val)
2394 return &Value{data: selected}
2398 // GroupFloat32 uses the specified grouper function to group the items
2399 // keyed by the return of the grouper. The object contained in the
2400 // result will contain a map[string][]float32.
2401 func (v *Value) GroupFloat32(grouper func(int, float32) string) *Value {
2403 groups := make(map[string][]float32)
2405 v.EachFloat32(func(index int, val float32) bool {
2406 group := grouper(index, val)
2407 if _, ok := groups[group]; !ok {
2408 groups[group] = make([]float32, 0)
2410 groups[group] = append(groups[group], val)
2414 return &Value{data: groups}
2418 // ReplaceFloat32 uses the specified function to replace each float32s
2419 // by iterating each item. The data in the returned result will be a
2420 // []float32 containing the replaced items.
2421 func (v *Value) ReplaceFloat32(replacer func(int, float32) float32) *Value {
2423 arr := v.MustFloat32Slice()
2424 replaced := make([]float32, len(arr))
2426 v.EachFloat32(func(index int, val float32) bool {
2427 replaced[index] = replacer(index, val)
2431 return &Value{data: replaced}
2435 // CollectFloat32 uses the specified collector function to collect a value
2436 // for each of the float32s in the slice. The data returned will be a
2438 func (v *Value) CollectFloat32(collector func(int, float32) interface{}) *Value {
2440 arr := v.MustFloat32Slice()
2441 collected := make([]interface{}, len(arr))
2443 v.EachFloat32(func(index int, val float32) bool {
2444 collected[index] = collector(index, val)
2448 return &Value{data: collected}
2452 Float64 (float64 and []float64)
2453 --------------------------------------------------
2456 // Float64 gets the value as a float64, returns the optionalDefault
2457 // value or a system default object if the value is the wrong type.
2458 func (v *Value) Float64(optionalDefault ...float64) float64 {
2459 if s, ok := v.data.(float64); ok {
2462 if len(optionalDefault) == 1 {
2463 return optionalDefault[0]
2468 // MustFloat64 gets the value as a float64.
2470 // Panics if the object is not a float64.
2471 func (v *Value) MustFloat64() float64 {
2472 return v.data.(float64)
2475 // Float64Slice gets the value as a []float64, returns the optionalDefault
2476 // value or nil if the value is not a []float64.
2477 func (v *Value) Float64Slice(optionalDefault ...[]float64) []float64 {
2478 if s, ok := v.data.([]float64); ok {
2481 if len(optionalDefault) == 1 {
2482 return optionalDefault[0]
2487 // MustFloat64Slice gets the value as a []float64.
2489 // Panics if the object is not a []float64.
2490 func (v *Value) MustFloat64Slice() []float64 {
2491 return v.data.([]float64)
2494 // IsFloat64 gets whether the object contained is a float64 or not.
2495 func (v *Value) IsFloat64() bool {
2496 _, ok := v.data.(float64)
2500 // IsFloat64Slice gets whether the object contained is a []float64 or not.
2501 func (v *Value) IsFloat64Slice() bool {
2502 _, ok := v.data.([]float64)
2506 // EachFloat64 calls the specified callback for each object
2507 // in the []float64.
2509 // Panics if the object is the wrong type.
2510 func (v *Value) EachFloat64(callback func(int, float64) bool) *Value {
2512 for index, val := range v.MustFloat64Slice() {
2513 carryon := callback(index, val)
2514 if carryon == false {
2523 // WhereFloat64 uses the specified decider function to select items
2524 // from the []float64. The object contained in the result will contain
2525 // only the selected items.
2526 func (v *Value) WhereFloat64(decider func(int, float64) bool) *Value {
2528 var selected []float64
2530 v.EachFloat64(func(index int, val float64) bool {
2531 shouldSelect := decider(index, val)
2532 if shouldSelect == false {
2533 selected = append(selected, val)
2538 return &Value{data: selected}
2542 // GroupFloat64 uses the specified grouper function to group the items
2543 // keyed by the return of the grouper. The object contained in the
2544 // result will contain a map[string][]float64.
2545 func (v *Value) GroupFloat64(grouper func(int, float64) string) *Value {
2547 groups := make(map[string][]float64)
2549 v.EachFloat64(func(index int, val float64) bool {
2550 group := grouper(index, val)
2551 if _, ok := groups[group]; !ok {
2552 groups[group] = make([]float64, 0)
2554 groups[group] = append(groups[group], val)
2558 return &Value{data: groups}
2562 // ReplaceFloat64 uses the specified function to replace each float64s
2563 // by iterating each item. The data in the returned result will be a
2564 // []float64 containing the replaced items.
2565 func (v *Value) ReplaceFloat64(replacer func(int, float64) float64) *Value {
2567 arr := v.MustFloat64Slice()
2568 replaced := make([]float64, len(arr))
2570 v.EachFloat64(func(index int, val float64) bool {
2571 replaced[index] = replacer(index, val)
2575 return &Value{data: replaced}
2579 // CollectFloat64 uses the specified collector function to collect a value
2580 // for each of the float64s in the slice. The data returned will be a
2582 func (v *Value) CollectFloat64(collector func(int, float64) interface{}) *Value {
2584 arr := v.MustFloat64Slice()
2585 collected := make([]interface{}, len(arr))
2587 v.EachFloat64(func(index int, val float64) bool {
2588 collected[index] = collector(index, val)
2592 return &Value{data: collected}
2596 Complex64 (complex64 and []complex64)
2597 --------------------------------------------------
2600 // Complex64 gets the value as a complex64, returns the optionalDefault
2601 // value or a system default object if the value is the wrong type.
2602 func (v *Value) Complex64(optionalDefault ...complex64) complex64 {
2603 if s, ok := v.data.(complex64); ok {
2606 if len(optionalDefault) == 1 {
2607 return optionalDefault[0]
2612 // MustComplex64 gets the value as a complex64.
2614 // Panics if the object is not a complex64.
2615 func (v *Value) MustComplex64() complex64 {
2616 return v.data.(complex64)
2619 // Complex64Slice gets the value as a []complex64, returns the optionalDefault
2620 // value or nil if the value is not a []complex64.
2621 func (v *Value) Complex64Slice(optionalDefault ...[]complex64) []complex64 {
2622 if s, ok := v.data.([]complex64); ok {
2625 if len(optionalDefault) == 1 {
2626 return optionalDefault[0]
2631 // MustComplex64Slice gets the value as a []complex64.
2633 // Panics if the object is not a []complex64.
2634 func (v *Value) MustComplex64Slice() []complex64 {
2635 return v.data.([]complex64)
2638 // IsComplex64 gets whether the object contained is a complex64 or not.
2639 func (v *Value) IsComplex64() bool {
2640 _, ok := v.data.(complex64)
2644 // IsComplex64Slice gets whether the object contained is a []complex64 or not.
2645 func (v *Value) IsComplex64Slice() bool {
2646 _, ok := v.data.([]complex64)
2650 // EachComplex64 calls the specified callback for each object
2651 // in the []complex64.
2653 // Panics if the object is the wrong type.
2654 func (v *Value) EachComplex64(callback func(int, complex64) bool) *Value {
2656 for index, val := range v.MustComplex64Slice() {
2657 carryon := callback(index, val)
2658 if carryon == false {
2667 // WhereComplex64 uses the specified decider function to select items
2668 // from the []complex64. The object contained in the result will contain
2669 // only the selected items.
2670 func (v *Value) WhereComplex64(decider func(int, complex64) bool) *Value {
2672 var selected []complex64
2674 v.EachComplex64(func(index int, val complex64) bool {
2675 shouldSelect := decider(index, val)
2676 if shouldSelect == false {
2677 selected = append(selected, val)
2682 return &Value{data: selected}
2686 // GroupComplex64 uses the specified grouper function to group the items
2687 // keyed by the return of the grouper. The object contained in the
2688 // result will contain a map[string][]complex64.
2689 func (v *Value) GroupComplex64(grouper func(int, complex64) string) *Value {
2691 groups := make(map[string][]complex64)
2693 v.EachComplex64(func(index int, val complex64) bool {
2694 group := grouper(index, val)
2695 if _, ok := groups[group]; !ok {
2696 groups[group] = make([]complex64, 0)
2698 groups[group] = append(groups[group], val)
2702 return &Value{data: groups}
2706 // ReplaceComplex64 uses the specified function to replace each complex64s
2707 // by iterating each item. The data in the returned result will be a
2708 // []complex64 containing the replaced items.
2709 func (v *Value) ReplaceComplex64(replacer func(int, complex64) complex64) *Value {
2711 arr := v.MustComplex64Slice()
2712 replaced := make([]complex64, len(arr))
2714 v.EachComplex64(func(index int, val complex64) bool {
2715 replaced[index] = replacer(index, val)
2719 return &Value{data: replaced}
2723 // CollectComplex64 uses the specified collector function to collect a value
2724 // for each of the complex64s in the slice. The data returned will be a
2726 func (v *Value) CollectComplex64(collector func(int, complex64) interface{}) *Value {
2728 arr := v.MustComplex64Slice()
2729 collected := make([]interface{}, len(arr))
2731 v.EachComplex64(func(index int, val complex64) bool {
2732 collected[index] = collector(index, val)
2736 return &Value{data: collected}
2740 Complex128 (complex128 and []complex128)
2741 --------------------------------------------------
2744 // Complex128 gets the value as a complex128, returns the optionalDefault
2745 // value or a system default object if the value is the wrong type.
2746 func (v *Value) Complex128(optionalDefault ...complex128) complex128 {
2747 if s, ok := v.data.(complex128); ok {
2750 if len(optionalDefault) == 1 {
2751 return optionalDefault[0]
2756 // MustComplex128 gets the value as a complex128.
2758 // Panics if the object is not a complex128.
2759 func (v *Value) MustComplex128() complex128 {
2760 return v.data.(complex128)
2763 // Complex128Slice gets the value as a []complex128, returns the optionalDefault
2764 // value or nil if the value is not a []complex128.
2765 func (v *Value) Complex128Slice(optionalDefault ...[]complex128) []complex128 {
2766 if s, ok := v.data.([]complex128); ok {
2769 if len(optionalDefault) == 1 {
2770 return optionalDefault[0]
2775 // MustComplex128Slice gets the value as a []complex128.
2777 // Panics if the object is not a []complex128.
2778 func (v *Value) MustComplex128Slice() []complex128 {
2779 return v.data.([]complex128)
2782 // IsComplex128 gets whether the object contained is a complex128 or not.
2783 func (v *Value) IsComplex128() bool {
2784 _, ok := v.data.(complex128)
2788 // IsComplex128Slice gets whether the object contained is a []complex128 or not.
2789 func (v *Value) IsComplex128Slice() bool {
2790 _, ok := v.data.([]complex128)
2794 // EachComplex128 calls the specified callback for each object
2795 // in the []complex128.
2797 // Panics if the object is the wrong type.
2798 func (v *Value) EachComplex128(callback func(int, complex128) bool) *Value {
2800 for index, val := range v.MustComplex128Slice() {
2801 carryon := callback(index, val)
2802 if carryon == false {
2811 // WhereComplex128 uses the specified decider function to select items
2812 // from the []complex128. The object contained in the result will contain
2813 // only the selected items.
2814 func (v *Value) WhereComplex128(decider func(int, complex128) bool) *Value {
2816 var selected []complex128
2818 v.EachComplex128(func(index int, val complex128) bool {
2819 shouldSelect := decider(index, val)
2820 if shouldSelect == false {
2821 selected = append(selected, val)
2826 return &Value{data: selected}
2830 // GroupComplex128 uses the specified grouper function to group the items
2831 // keyed by the return of the grouper. The object contained in the
2832 // result will contain a map[string][]complex128.
2833 func (v *Value) GroupComplex128(grouper func(int, complex128) string) *Value {
2835 groups := make(map[string][]complex128)
2837 v.EachComplex128(func(index int, val complex128) bool {
2838 group := grouper(index, val)
2839 if _, ok := groups[group]; !ok {
2840 groups[group] = make([]complex128, 0)
2842 groups[group] = append(groups[group], val)
2846 return &Value{data: groups}
2850 // ReplaceComplex128 uses the specified function to replace each complex128s
2851 // by iterating each item. The data in the returned result will be a
2852 // []complex128 containing the replaced items.
2853 func (v *Value) ReplaceComplex128(replacer func(int, complex128) complex128) *Value {
2855 arr := v.MustComplex128Slice()
2856 replaced := make([]complex128, len(arr))
2858 v.EachComplex128(func(index int, val complex128) bool {
2859 replaced[index] = replacer(index, val)
2863 return &Value{data: replaced}
2867 // CollectComplex128 uses the specified collector function to collect a value
2868 // for each of the complex128s in the slice. The data returned will be a
2870 func (v *Value) CollectComplex128(collector func(int, complex128) interface{}) *Value {
2872 arr := v.MustComplex128Slice()
2873 collected := make([]interface{}, len(arr))
2875 v.EachComplex128(func(index int, val complex128) bool {
2876 collected[index] = collector(index, val)
2880 return &Value{data: collected}