You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
27 lines
673 B
Go
27 lines
673 B
Go
2 years ago
|
package component
|
||
|
|
||
|
type (
|
||
|
options struct {
|
||
|
serviceName string // 自定义服务名
|
||
|
methodNameFunc func(string) string // 自定义方法名钩子
|
||
|
}
|
||
|
|
||
|
Option func(options *options)
|
||
|
)
|
||
|
|
||
|
// WithServiceName 覆盖默认生成的服务名称
|
||
|
func WithServiceName(name string) Option {
|
||
|
return func(options *options) {
|
||
|
options.serviceName = name
|
||
|
}
|
||
|
}
|
||
|
|
||
|
// WithMethodNameFunc 覆盖默认生成的方法名
|
||
|
// 当前仅支持一些基本策略,如: strings.ToUpper/strings.ToLower
|
||
|
// 或自行根据方法名判断后进行重写
|
||
|
func WithMethodNameFunc(fn func(string) string) Option {
|
||
|
return func(options *options) {
|
||
|
options.methodNameFunc = fn
|
||
|
}
|
||
|
}
|