-
Notifications
You must be signed in to change notification settings - Fork 14
/
util.go
45 lines (39 loc) · 986 Bytes
/
util.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
package proto2api
import "strings"
// SkipRpcName returns true when the rpc should be skipped
func SkipRpcName(rpcName, modelName string) bool {
if rpcName == ("create"+modelName) ||
rpcName == ("update"+modelName) ||
rpcName == ("delete"+modelName) ||
rpcName == ("get"+modelName+"List") ||
rpcName == ("get"+modelName+"ById") {
return true
}
return false
}
func SkipBaseMessage(messageName string) bool {
switch messageName {
case "Empty", "IDReq", "IDsReq", "UUIDsReq", "UUIDReq", "BaseResp", "PageInfoReq",
"BaseMsg", "BaseIDResp", "BaseUUIDResp":
return true
}
return false
}
func FindTypeContentIndex(data string) int {
beginIndex := strings.Index(data, "type ")
for i := beginIndex; i < len(data); i++ {
if data[i] == '(' {
return i
}
}
return -1
}
func FindServiceContentIndex(data string) int {
beginIndex := strings.Index(data, "service ")
for i := beginIndex; i < len(data); i++ {
if data[i] == '{' {
return i
}
}
return -1
}