-
Notifications
You must be signed in to change notification settings - Fork 0
/
option.go
62 lines (57 loc) · 2.82 KB
/
option.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
package protokit
import (
"io"
"strings"
)
type FileExcludeFilter = func(string) bool
type FileAccessor = func(fielRelativePath string) (io.ReadCloser, error)
// 默认过滤器
func defaultFileExcludeFilter(filePath string) bool {
return strings.Contains(filePath, "_exclude")
}
//go:generate optionGen --xconf=true --usage_tag_name=usage --xconf=true
func OptionsOptionDeclareWithDefault() interface{} {
return map[string]interface{}{
// annotation@GolangBasePackagePath(comment="golang基础package path")
"GolangBasePackagePath": string(""),
// annotation@GolangRelative(comment="是否启用golang relative模式")
"GolangRelative": true,
// annotation@ProtoImportPath(comment="proto import路径")
"ProtoImportPath": []string{},
// annotation@ProtoFileAccessor(comment="proto import路径")
"ProtoFileAccessor": FileAccessor(nil),
// annotation@ProtoFileExcludeFilter(comment="proto过滤")
"ProtoFileExcludeFilter": FileExcludeFilter(defaultFileExcludeFilter),
// annotation@ZapLogMapKeyTypes(comment="以类型为key的map的MarshalLogObject实现,使得可以直接使用zap.Object函数打印map数据")
"ZapLogMapKeyTypes": []string{"int", "int32", "int64", "uint32", "uint64", "string"},
// annotation@ZapLogBytesMode(comment="zap以何种方式输出[]byte, 可以使用base64或者bytes, 默认bytes")
"ZapLogBytesMode": "bytes",
// annotation@NamePattern(comment="名称格式化空自己",inline="true")
"NamePattern": (*NamePattern)(NewNamePattern()),
// annotation@ImportSetExclude(comment="import set忽略指定name的package")
"ImportSetExclude": []string{"netutils"},
// annotation@URIUsingGRPC(comment="service的uri是否使用GRPC模式")
"URIUsingGRPC": false,
// annotation@InvalidServiceAnnotations(comment="非法的 service annotations")
"InvalidServiceAnnotations": []string{},
// annotation@URIUsingGRPCWithoutPackage(comment="service的uri使用GRPC模式时,是否带package名")
"URIUsingGRPCWithoutPackage": false,
// annotation@StrictMode(comment="是否为严格模式")
"StrictMode": true,
}
}
//go:generate optionGen --xconf=true --usage_tag_name=usage --xconf=true
func NamePatternOptionDeclareWithDefault() interface{} {
return map[string]interface{}{
// annotation@NamePatternServerHandler(comment="code server handler名称格式化")
"NamePatternServerHandler": "ServerHandler%s",
// annotation@NamePatternRPCClient(comment="code rpc client名称格式化")
"NamePatternRPCClient": "RPCClient%s",
// annotation@NamePatternActorClient(comment="code actor client名称格式化")
"NamePatternActorClient": "ActorClient%s",
// annotation@NamePatternERPCClient(comment="code erpc client名称格式化")
"NamePatternERPCClient": "ERPCClient%s",
// annotation@NamePatternHTTPPath(comment="自动生成的HTTP PATHG格式")
"NamePatternHTTPPath": "%s",
}
}