/
misc.go
41 lines (32 loc) · 911 Bytes
/
misc.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
package mcore
import (
"fmt"
"strings"
)
// check value if null or blank
func CheckNullOrBlank(value interface{}, format string, args ...interface{}) bool {
return CheckNullOrBlankWithErrMsg(value, fmt.Sprintf(format, args...))
}
func CheckNullOrBlankWithErrMsg(value interface{}, errMsg string) bool {
if String(fmt.Sprintf("%v", value)).IsBlank() {
fmt.Println(errMsg)
return true
}
return false
}
// IsIncludeExcludeIn
func IsIncludeExcludeIn(field string, fields []string, include, exclude string) bool {
includes := strings.Split(include, ",")
excludes := strings.Split(exclude, ",")
keyString := String(field)
// exist include and not in include, false
if include != "" && !keyString.IsInArrayIgnoreCase(includes) {
return false
}
// if include == "", then only check exclude
// in exclude, false
if keyString.IsInArrayIgnoreCase(excludes) {
return false
}
return true
}