refactor(service): 优化Use函数参数类型

移除Use函数中initFunc参数的指针包装,直接使用func() error类型。
简化函数内部调用逻辑,提升代码可读性和健壮性。
```
This commit is contained in:
yanweidong 2025-09-23 12:41:31 +08:00
parent 44319d03b9
commit f681f0bb17
1 changed files with 5 additions and 8 deletions

View File

@ -108,14 +108,11 @@ func (s *Service) Gateway(grpcAddr string, httpAddr string) {
http.ListenAndServe(httpAddr, s.Opts.GatewayMux)
}
func (s *Service) Use(initFunc *func() error) {
// Execute the Init function if it's not nil
if initFunc != nil {
err := (*initFunc)()
if err != nil {
print.Error(err.Error())
panic(err)
}
func (s *Service) Use(initFunc func() error) {
err := (initFunc)()
if err != nil {
print.Error(err.Error())
panic(err)
}
}