This repository was archived by the owner on Apr 23, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathint.go
105 lines (94 loc) · 2.05 KB
/
int.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
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
// Copyright 2018 Romano de Souza. All rights reserved.
// Use of this source code is governed by a MIT-style
// license that can be found in the LICENSE file.
package coalesce
// Int returns the first non-nil value in a list of pointers to int.
func Int(args ...*int) *int {
for _, arg := range args {
if arg != nil {
return arg
}
}
return nil
}
// IntSlice returns the first non-nil value in a list of slice of int.
func IntSlice(args ...[]int) []int {
for _, arg := range args {
if arg != nil {
return arg
}
}
return nil
}
// Int8 returns the first non-nil value in a list of pointers to int8.
func Int8(args ...*int8) *int8 {
for _, arg := range args {
if arg != nil {
return arg
}
}
return nil
}
// Int8Slice returns the first non-nil value in a list of slice of int8.
func Int8Slice(args ...[]int8) []int8 {
for _, arg := range args {
if arg != nil {
return arg
}
}
return nil
}
// Int16 returns the first non-nil value in a list of pointers to int16.
func Int16(args ...*int16) *int16 {
for _, arg := range args {
if arg != nil {
return arg
}
}
return nil
}
// Int16Slice returns the first non-nil value in a list of slice of int16.
func Int16Slice(args ...[]int16) []int16 {
for _, arg := range args {
if arg != nil {
return arg
}
}
return nil
}
// Int32 returns the first non-nil value in a list of pointers to int32.
func Int32(args ...*int32) *int32 {
for _, arg := range args {
if arg != nil {
return arg
}
}
return nil
}
// Int32Slice returns the first non-nil value in a list of slice of int32.
func Int32Slice(args ...[]int32) []int32 {
for _, arg := range args {
if arg != nil {
return arg
}
}
return nil
}
// Int64 returns the first non-nil value in a list of pointers to int64.
func Int64(args ...*int64) *int64 {
for _, arg := range args {
if arg != nil {
return arg
}
}
return nil
}
// Int64Slice returns the first non-nil value in a list of slice of int64.
func Int64Slice(args ...[]int64) []int64 {
for _, arg := range args {
if arg != nil {
return arg
}
}
return nil
}