-
Notifications
You must be signed in to change notification settings - Fork 0
/
check_value.go
73 lines (63 loc) · 1.44 KB
/
check_value.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
package done
import "github.com/pkg/errors"
// Sure means the value is not zero value, then return value
func Sure[V comparable](v V) V {
var zero V
if !(v != zero) {
panic(errors.New("SHOULD BE SURE BUT IS ZERO"))
}
return v
}
// Nice means the value is not zero value, then return value
func Nice[V comparable](v V) V {
var zero V
if !(v != zero) {
panic(errors.New("SHOULD BE NICE BUT IS ZERO"))
}
return v
}
// Good means the value is not zero value, then return value
func Good[V comparable](v V) {
var zero V
if !(v != zero) {
panic(errors.New("SHOULD BE GOOD BUT IS ZERO"))
}
}
// Fine means the value is not zero value
func Fine[V comparable](v V) {
var zero V
if !(v != zero) {
panic(errors.New("SHOULD BE Fine BUT IS ZERO"))
}
}
// Safe means the value is not zero value
func Safe[V comparable](v V) {
var zero V
if !(v != zero) {
panic(errors.New("SHOULD BE SAFE BUT IS ZERO"))
}
}
// Zero means the value is a zero value, num is 0, string is "", PTR is none.
func Zero[V comparable](v V) {
var zero V
if !(v == zero) {
panic(errors.New("SHOULD BE ZERO BUT NOT ZERO"))
}
}
// None means the value is a zero value
func None[V comparable](v V) {
var zero V
if !(v == zero) {
panic(errors.New("SHOULD BE NONE BUT NOT NONE"))
}
}
func Null[T any](v *T) {
if v != nil {
panic(errors.New("SHOULD BE NULL BUT IS FULL"))
}
}
func Full[T any](v *T) {
if v == nil {
panic(errors.New("SHOULD BE FULL BUT IS NULL"))
}
}