-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathutil.go
More file actions
executable file
·80 lines (78 loc) · 1.71 KB
/
util.go
File metadata and controls
executable file
·80 lines (78 loc) · 1.71 KB
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
package f
import (
"github.com/google/uuid"
ge "github.com/og/x/error"
"reflect"
"regexp"
"strings"
)
type Map map[string]interface{}
func UUID() string {
return uuid.New().String()
}
func GetUUID32 (uuid string) string {
separator, err := regexp.Compile(`-`) ; ge.Check(err)
return separator.ReplaceAllString(uuid, "")
}
func GetUUID36(uuid32 string) string {
uuid := ""
for i:=0;i<len(uuid32);i++ {
uuid += string(uuid32[i])
switch i {
case 7, 11, 15, 19:
uuid += "-"
}
}
return uuid
}
// 解决数据库字段新增,但是没有通知go导致的解析问题
func scanModelMakeSQLSelect(modelType reflect.Type, qb *QB) {
if len(qb.Select) == 0 {
selectList := []string{}
for i:=0;i<modelType.NumField();i++ {
dbTag, hasDBTag := modelType.Field(i).Tag.Lookup("db")
if !hasDBTag {
continue
}
selectList = append(selectList, dbTag)
}
qb.Select = selectList
}
}
type stringQueue struct {
Value []string
}
func (v *stringQueue) Push(args... string) {
v.Value = append(v.Value, args...)
}
func (sList *stringQueue) Pop() stringQueue {
return sList.PopBind(&stringQueueBindValue{})
}
type stringQueueBindValue struct {
Value string
Has bool
}
func (sList *stringQueue) PopBind(last *stringQueueBindValue) stringQueue {
listLen := len(sList.Value)
if listLen == 0 {
/*
Clear StringListBindValue Because in this case
```
list.PopBind(&last)
// do Something..
list.PopBind(&last)
```
last test same var
*/
last.Value = ""
last.Has = false
return *sList
}
last.Value = sList.Value[listLen-1]
last.Has = true
sList.Value = sList.Value[:listLen-1]
return *sList
}
func (v stringQueue) Join(separator string) string {
return strings.Join(v.Value, separator)
}